6/18 Help


#1

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

Oops, try again. Looks like cubes_by_four is the wrong length. It should have 5 values. I dont know what to do...


#2
cubes_by_four =[ x**3 for x in range(1,11) if x%2==0]
print cubes_by_four

x**2 gives square of x, x**3 give cube of x.


#3

You are actually quite close:

cubes_by_four = [x**3 for x in range(1,11) if x%2 == 0]

print cubes_by_four

It sucks because it is hard to see it, but by evenly divisible they mean divisible by 2 to a 0 remainder, not by 4. Hard to decipher I know, but such things are to be expected in programming every once in a while. Any way, hope this helps!


#4

why you are using this condition

when it says
"The comprehension should consist of the cubes of the numbers 1 through 10 only if the cube is evenly divisible by four."
that means if cube is divisible by four.


#5

Thanks Guys for the help. I didn't realize I had to mod it by 2 :\


#6

Mon, it's should be like this cubes_by_four = [x**3 for x in range(1,11) if x**3 % 4 == 0]


#9