Any (iterable)
Role:
If any element of iterable is not 0, ' ', False,all (iterable) returns True. Returns False if Iterable is empty.
The function is equivalent to:
1 def Any (iterable): 2 for inch iterable: 3 if element:4 return False 5 return True
Parameter iterable: an iterative object;
Instance:
1>>> any (['a','b','C','D'])#list, elements are not empty or 02 True3>>> any (['a','b',"','D'])#List of lists, there is an empty element4 True5>>> any ([0,"', False])#list, elements are all 0, ', False6 False7 8>>> any ('a','b','C','D'))#tuples tuple, elements are not empty or 09 TrueTen>>> any ('a','b',"','D'))#tuples tuple, there is an empty element One True A>>> any (0,"', False))#tuples tuple, element all 0, ', False - False - the ->>> any ([])#Empty list - False ->>> any (())#Empty tuple +False
Attention:
Compare the function with the all () function, any is arbitrary , and all is all . Suggest the difference between learning and the relationship between the two
Python function-any ()