Useful code examples and solutions I've collected. Feel free to use and learn from them!
// Python List Comprehension
// Create lists using comprehension syntax
# Basic list comprehension
squares = [x**2 for x in range(10)]
print(squares)
# With condition
even_squares = [x**2 for x in range(10) if x % 2 == 0]
print(even_squares)
# Nested comprehension
matrix = [[i+j for j in range(3)] for i in range(3)]
print(matrix)