Any (iterable)
Version: This function is suitable for version 2.5 and above, compatible with Python3 version.
Description: If any element of iterable does not return true for 0, ' ', False,all (iterable). Returns False if Iterable is empty. The function is equivalent to:
Note the difference between the function and the all () function, any is arbitrary, and all is all. It is suggested to compare and learn the difference between the two. You can refer to the Python function for a daily talk-all ()
def any (iterable):
For element in iterable:
If element:
Return False
Return True
Parameter iterable: an iterative object;
Example:
>>> any ([' A ', ' B ', ' C ', ' d ']) #列表list, the elements are not empty or 0
True
>>> any ([' A ', ' B ', ' ', ' d ']) #列表list, there is an empty element
True
>>> any ([0, ', false]) #列表list, the element is all 0, ', false
False
>>> any (' A ', ' B ', ' C ', ' d ') #元组tuple, the elements are not empty or 0
True
>>> any (' A ', ' B ', ' ', ' d ') #元组tuple, there is an empty element
True
>>> any (0, ', false) #元组tuple, element is all 0, ', false
False
>>> any ([]) # Empty list
False
>>> any (()) # Empty tuple
False