How to use the any () function and all () function in Python
This article mainly explains how to use any() function and all() function in Python. Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn how to use any() function and all() function in Python.
Recall that when programming in Python, did you ever need to check whether any or all elements of an iterable object (such as a list) evaluated True?
Suppose we want to determine whether all the numbers in a list of numbers are greater than 0, and you would probably do this:
a = [1, 2, 3, 4]def is_big_0(l): #Determine whether all numbers in list l are greater than 0, if greater than 0, return True, otherwise return False for i in l: if i