Practice with comprehensions#
Define a function that uses range
and a list comprehension to generate the cubes of all numbers up to some n
, inclusive. Call your function cubes
.
Here’s an example interaction:
>>> cubes(10)
[0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]