Python

Codecademy

Ajax-loader-large-white
6/18
Advanced Topics in Python
Now You Try!

Great work! Now it's time for you to create a list comprehension all on your own.

c = ['C' for x in range(5) if x < 3]
print c

The example above creates and prints out a list containing ['C', 'C', 'C'].

Instructions
  1. Use a list comprehension to create a list, 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.
  3. Finally, print that list to the console.

Note that in this case, the cubed number should be evenly divisible by 4, not the original number.

script.py

Sign in