6. Now You Try!



Oops, try again. Looks like cubes_by_four is the wrong length. It should have 5 values.

Well, I was pretty sure this should work, but it doesn't. No idea what went wrong.

cubes_by_four = [c**3 for c in range(1, 11) if (c**3) & 4 == 0]
print cubes_by_four


The comprehension should consist of the cubes of the numbers 1 through 10 only if the cube is evenly divisible by four.

to calculate if a number is divisible by a certain number (4 in this case) you should use the modulo operator, & is a bitwise operator (you will learn about this in the next section)


Thank you. I am clearly an idiot for making a typo like that :smile: