Use any function to check True if any element of the iterable is true in python
Check True if any element of the iterable is true
any
function
returns True if any element of the iterable is true.
Equivalent to:/*from w w w .jav a 2s . co m*/
# def any(iterable):
# for element in iterable:
# if element:
# return True
# return False
print any(['A', '', 'B'])
The code above generates the following result.