Python’s built-in any() returns True when at least one item in an iterable is truthy; it returns False if none are truthy or the iterable is empty. It returns a Boolean, not the item that matched, and requires no import.
How any() works
Pass any() an iterable, such as a list, tuple, or generator. Python checks each element using its usual truth-value rules and stops as soon as it finds a truthy one. If iteration finishes without finding one, the result is False.
As an Amazon Associate I earn from qualifying purchases.
any([False, False, True]) # True
any([0, "", None]) # False
any([]) # False
That behavior is captured by the documented equivalent:
Free tools Windows power users keep installed
One-click scans. No signup required.
def any(iterable):
for element in iterable:
if element:
return True
return False
This is a conceptual equivalent, not code you need to define: any() is already available as a Python built-in.
#1 Best Overall
What counts as true?
any() does not look only for the literal value True. It tests each item according to Python’s truth-value rules. For built-in values, zero, an empty string, and None are false; nonzero numbers and non-empty strings are true. By default, an object is true unless its class defines __bool__() to return False or defines __len__() to return zero. See the Python 3.14.7 built-in types documentation for these rules.
If a custom truth-testing method raises an exception, that exception propagates; any() does not convert it into False.
Rank #2
Use a predicate when you have a specific condition
When the question is whether any item meets a condition, put that condition in a generator expression. Each generated result is then truth-tested by any().
Recommended Free Tools
numbers = [1, 3, 8]
any(number > 5 for number in numbers) # True
This asks whether at least one number is greater than five. The generator expression yields a Boolean for each number, and iteration can stop at the first True.
How any() differs from all()
Use any() for an “at least one” question and all() for an “every item” question. Both return Booleans, but their results for an empty iterable differ:
| Function | Question | Result for an empty iterable |
|---|---|---|
any(iterable) |
Is at least one item truthy? | False |
all(iterable) |
Are all items truthy? | True |
The Python built-in functions reference documents both behaviors and provides the equivalent loop for any().
Quick Recap
Best Value
Common mistakes to avoid
- Expecting the matching item:
any()returns onlyTrueorFalse; it does not return the first truthy element. - Looking only for literal
True: any truthy value can make the result true, including a nonzero number or non-empty string. - Passing a non-iterable: the argument must be iterable; a scalar value by itself is not a valid input.
- Using truthiness when the rule is narrower: express the intended test directly in a generator expression, such as
any(item > threshold for item in items).
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →




