Now You Try it!>>>HELP


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?


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


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.


i already mentioned why this problem still occurs?


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


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

to include 10,



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


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