How to remove tuples from a list of tuples according to specific condition in Python

1 Answer

0 votes
lst_tpl = [('a', 12), ('b', 32), ('c', 17), ('d', 5), ('e', 2), ('f', 43)] 

new_lst_tpl = [val for val in lst_tpl if val[1] > 16] 
  
print (str(new_lst_tpl)) 



'''
run:

[('b', 32), ('c', 17), ('f', 43)]

'''

 



answered Dec 15, 2019 by avibootz
...