Now you try!


I am getting invalid syntax

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


you want to result of list comprehension in a variable, assigning values to variable requires a single equal sign, which is missing in your case


Also you should edit range(1,10) and change it into range(1,11)
Remember that the last number is not contained in the creation list of range function.
For example:
my_list=range(0,3) # [0,1,2]
my_list=range(0,4) # [0,1,2,3]


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