List comprehension

[x * x for x in range(4)] = [0, 1, 4, 9]

You can also choose a level by clicking its number.

About the course

Description
The notation [expression for x in … if condition] creates a new list
More information
The examples are in Python. Indentation determines what belongs to a loop or a condition.
Sample question
[x * x for x in range(4)] = [0, 1, 4, 9]
Author
Jiří Preisler
Version
1.0