"""author: @pythonpips"""

numbers = [1, 2, 3, 4, 5]
squares = [number**2 for number in numbers]

# squares outputs: [1, 4, 9, 16, 25]
How to List Comprehension in Python

Subscribe to our newsletter