All (iterable)
Version: This function appears for the first time in the python2.5 version, and is suitable for 2.5 or more versions, including Python3, compatible with the Python3 version.
Description: If all elements of iterable are not 0, ', false, or iterable null, all (iterable) returns True, otherwise false; The function is equivalent to:
def all (iterable): for element in iterable: if not element: return False return True
Parameter iterable: an iterative object;
Example:
>>> all ([' A ', ' B ', ' C ', ' d ']) #列表list, the elements are not empty or 0true>>> all ([' A ', ' B ', ', ' d ']) #列表list, There is an empty element false>>> all ([0, 3]) #列表list, there is an element of 0 false >>> all ((' A ', ' B ', ' C ', ' d ')) #元组tuple, the elements are not empty or 0true>>> all ((' A ', ' B ', ', ' d ') #元组tuple, there is an empty element false>>> all (0, 1, 2, 3)) #元组tuple, there is an element of 0 false >>> all ([]) # Empty list true>>> All (()) # Empty tuple True
Note: Empty tuple, empty list return value is true, here is to pay special attention to