Skip to content

Chapter 15: List Comprehensions

List comprehensions provide a concise way to create lists.

Example

Python
squares = [x**2 for x in range(10)]

This creates a list of squares from 0 to 9.