6. Now You Try!


#1



https://www.codecademy.com/en/courses/python-beginner-en-KAgt5/1/3?curriculum_id=4f89dab3d788890003000096


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


#2

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)


#3

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


#4