List comprehensions

A list comprehension builds a list in one readable line — the most Pythonic idiom you’ll use daily.

`[expr for item in iterable if condition]` maps each item, optionally filtering. It replaces a for-loop that keeps calling `.append()`.

squares = [n * n for n in range(5)]
# [0, 1, 4, 9, 16]

More lessons in Pythonic essentials