How to list comprehension using multiple if condition in Python

1 Answer

0 votes
lst = [5, 12, 8, 9, 0, 1, 2, 4, -6]

lstc = [x for x in lst if x > 2 if x % 2 == 0]

print(lstc)


     
 
'''
run:
 
[12, 8, 4]
 
'''

 



answered Jan 11, 2021 by avibootz
...