Check if all values in list are greater than a certain number

后端 未结 7 904
太阳男子
太阳男子 2020-12-12 20:31
my_list1 = [30,34,56]
my_list2 = [29,500,43]

How to I check if all values in list are >= 30? my_list1 should work and my_list2

相关标签:
7条回答
  • 2020-12-12 20:56

    There is a builtin function all:

    all (x > limit for x in my_list)
    

    Being limit the value greater than which all numbers must be.

    0 讨论(0)
提交回复
热议问题