CKTIS / Python
any()
Returns true as soon as an element of the iterable passes a truth test.
Version: Python 3.14; repository image, production runtime not attested
Syntax
any(iterable, /)Returns true as soon as an element of the iterable passes a truth test.
An empty iterable produces false because it contains no successful element.
Look for one witness with a true value. Zero and the empty string fail, then 3 succeeds and scanning stops. If no such item exists, including when there are no items at all, the Boolean returned is False.
it = iter([0, "", 3, 4])
assert any(it) is True and next(it) == 4
assert any([]) is False
Examples
print(any([0, "", 3]))
print(any([]))
Result
True False
Look for one witness with a true value. Zero and the empty string fail, then 3 succeeds and scanning stops. If no such item exists, including when there are no items at all, the Boolean returned is False.