Now You Try it!>>>HELP


#1

cubes_by_four = [x**3 for x in range(1,10) if x%4==0]
print cubes_by_four

Please what's wrong with my code?


#2

10 should be included, but range does not include the stop value

from the instructions:
only if the cube is evenly divisible by four

so you have to take the remainder of the cube of x:

x ** 3 % 4 == 0

#3

cubes_by_four = [x**3 for x in range(1,10) if x**3%4==0]
print cubes_by_four

I changed it but it still didn't work. The error was: Oops, try again.
Looks like cubes_by_four is the wrong length. It should have 5 values.


#4

i already mentioned why this problem still occurs?


#5

I found the problem, I needed to add a parentheses to x**3


#6

All you need to do is change your range's stop value so that 10 is also included in the iteration,

to include 10,

range(1,11)


#7

Yeah thanks a lot. Can we have a private chat?


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.