How do Python's any and all functions work?

后端 未结 8 1565
挽巷
挽巷 2020-11-22 01:13

I\'m trying to understand how the any() and all() Python built-in functions work.

I\'m trying to compare the tuples so that if any value i

8条回答
  •  梦谈多话
    2020-11-22 01:55

    list = [1,1,1,0]
    print(any(list)) # will return True because there is  1 or True exists
    print(all(list)) # will return False because there is a 0 or False exists
    return all(a % i for i in range(3, int(a ** 0.5) + 1)) # when number is divisible it will return False else return True but the whole statement is False .
    

提交回复
热议问题