How to compare all items in a list with an integer without using for loop

前端 未结 6 1845
臣服心动
臣服心动 2021-01-14 06:25

I have a couple of lists which vary in length, and I would like to compare each of their items with an integer, and if any one of the items is above said integer, it breaks

6条回答
  •  臣服心动
    2021-01-14 07:04

    You can shorten it to this :D

    for good_list in filter(lambda x: max(x)<=70, listoflists):
       # do stuff
    

提交回复
热议问题