All (iterable)
Role:
If all elements of iterable are not 0, ', false, or iterable are empty, all (iterable) returns true, otherwise false; the function is equivalent to:
1 def all (iterable): 2 for inch iterable: 3 if not element: 4 return False 5 return True
Parameter iterable: an iterative object;
Instance:
1>>> All (['a','b','C','D'])#list, elements are not empty or 02 True3>>> All (['a','b',"','D'])#List of lists, there is an empty element4 False5>>> all ([0, 1, 2, 3])#List of lists, there is an element of 06 False7 8>>> All ('a','b','C','D'))#tuples tuple, elements are not empty or 09 TrueTen>>> All ('a','b',"','D'))#tuples tuple, There is an empty element one False a>>> all ((0, 1, 2, 3))#tuples tuple, There is an element of 0 - False - the ->>> All ([])#Empty list - True ->>> All (())#Empty tuple +True
Note: empty tuple, empty list return value is true, here is to pay special attention to
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.
Python function-all ()