"""author: @pythonpips"""

numbers = [1, 2, 3, 4, 5]
squares_of_even = [number**2 for number in numbers if number % 2 = 0]

# squares outputs: [4, 16]
How to List Comprehension with If Condition in Python

Subscribe to our newsletter