any
Check whether at least one item is truthy.
Python 3.13
any(iterable)- iterable
- The values to check.Iterable
Return value
True if at least one item is truthy, otherwise False; False for an empty iterable.
Examples
At least one value is true
Python 3.13
print(any([False, False, True]))True
Checking a condition for items
Python 3.13
print(any(x < 0 for x in [3, -1, 2]))True
Details
Iteration stops at the first truthy item. It is often used with a generator: any(x < 0 for x in numbers).
