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?

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.

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)`

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