Solution Review: List of Cubes

This lesson gives a detailed review of how to print a list of cubes using a list comprehension.

Solution1: List Comprehension

As we have already seen in the previous exercise, list comprehensions allow for in-place list creation using a range that mathematical operations can be done on. This solution uses the same approach; we can simply use a list comprehension that iterates over a range of 1-21, and cubes each element as it goes.

Get hands-on with 1200+ tech skills courses.