Multiple Conditions
Chain multiple if conditions in a comprehension to apply several filters at once.
Chain multiple if conditions in a comprehension to apply several filters at once.
result = [x for x in range(100)
if x % 2 == 0
if x % 3 == 0]
print(result)
# [0, 6, 12, 18, ...]
Multiple ifs are ANDed together — equivalent to "if a and b".