How to list comprehension using with if condition in Python

1 Answer

0 votes
lst = [5, 7, 8, 1, 0, 9, 2, 3]

lstc= [x * x for x in lst if (x % 2 == 0)]

print(lstc)


     
 
'''
run:
 
[64, 0, 4]
 
'''

 



answered Jan 11, 2021 by avibootz
...