Definition
The any() function returns True if any item in an iterable are true, otherwise it returns False.
When the iterable object is empty, the any() function will return False.
Syntax
any(iterable)
Parameters
| Parameter | Description |
|---|---|
| iterable | An iterable object. Could be a list, tuple or dictionary |
Examples
Tuple
t = (False, 1, False)
result = any(t)
print(result)
Set
s = {1, 1, 0}
result = any(s)
print(result)
Dictionary
s = {1, 1, 0}
result = any(s)
print(result)