Python has a compact syntax for creating lists from loops:
# Regular loop
squares = []
for x in range(5):
squares.append(x ** 2)
# List comprehension
squares = [x ** 2 for x in range(5)]
Both create [, , , , ]. The comprehension is more concise.
You can add conditions:
evens = [x for x in range(10) if x % 2 == 0]
We'll cover comprehensions fully in the next section on lists. For now, recognize the pattern.