Print an element in a list based on a condition

前端 未结 3 1709
难免孤独
难免孤独 2021-01-29 14:45

I have a list of lists which contain a first name, last name, and points scored.

list1 = [[\'david\', \'carter\', 6], [\'chris\', \'jenkins\', 0], [\'john\', \'w         


        
3条回答
  •  一向
    一向 (楼主)
    2021-01-29 15:23

    >>>[item for item in list1 if item[2]==0]
    
    ans:-
    [['chris', 'jenkins', 0], ['ryan', 'love', 0]]
    

提交回复
热议问题