Code
python
# Generate list of squares
squares = [x**2 for x in range(10)]
print(squares)
# Conditional comprehension
evens = [x for x in range(20) if x % 2 == 0]
# Nested comprehension
matrix = [[i * j for j in range(3)] for i in range(3)]
# Dict comprehension
word_len = {w: len(w) for w in ["hello", "world", "python"]}