Courses/Data Structures

๐Ÿ“ฆ Data Structures

List Comprehensions

Build lists with one expressive line.

List comprehensions create new lists from existing ones in a compact, readable way.

squares = [x * x for x in range(10)]
evens = [x for x in range(20) if x % 2 == 0]
main.py
Output
Press Run to execute.
Expected output
[1, 4, 9, 16, 25]

Sign in to track your progress across lessons.