๐ฆ 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]
๐ฆ Data Structures
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]
Press Run to execute.[1, 4, 9, 16, 25]
Sign in to track your progress across lessons.