The Python any() function returns True when at least one item in an iterable is truthy, and False when none is, including when the iterable is empty. Pair it with a generator expression to ask “does anything here match?” in one line:
any(total > 500 for total in [89.50, 612.00, 45.25]) # True
any([]) # False
I ran every example on this page on Python 3.12.5 in Command Prompt, so the outputs are real.
In this tutorial, we’ll cover which values count as true, conditions with generators, why any() stops early, strings and dictionaries, and how it compares with all().
Which values make Python any() return True?
Python’s any() tests each item’s truth value. Zero, empty strings, None, False and empty containers are falsy; nearly everything else is truthy:
print(any([0, "", None, False])) # every item is falsy
print(any([0, "", 3])) # 3 is truthy
print(any([])) # empty -> False
print(any([[], {}, ()])) # empty containers are falsy
print(any([[0]])) # a list holding 0 is not empty
print(any("0")) # the string "0" is truthy
Output:
False
True
False
False
True
True

Note the last two lines: [[0]] holds a non-empty list, and "0" is a non-empty string, so both count as true. The rules come from the Python bool() function, which any() applies to each item.
Check a condition across a list with any() and a generator
Most of the time you don’t have a list of booleans. You have records, and you want to know whether any of them passes a test. A generator expression builds those True/False answers one at a time:
orders = [
{"id": "A-1001", "state": "TX", "total": 89.50, "shipped": True},
{"id": "A-1002", "state": "CA", "total": 612.00, "shipped": True},
{"id": "A-1003", "state": "NY", "total": 45.25, "shipped": False},
]
big = any(o["total"] > 500 for o in orders)
print("Any order over $500.00?", big)
late = any(not o["shipped"] for o in orders)
print("Any order not shipped?", late)
print("Any order from Florida?", any(o["state"] == "FL" for o in orders))
first = next((o["id"] for o in orders if o["total"] > 500), None)
print("First big order:", first)
Output:
Any order over $500.00? True
Any order not shipped? True
Any order from Florida? False
First big order: A-1002

any() only says yes or no. When you need the matching item itself, next() with a default returns the first match, as the last line shows. For keeping every match instead, see filtering lists in Python.
Does Python any() stop at the first True value?
Yes. any() short-circuits: it stops reading as soon as it finds a truthy item. That only saves work when the items are produced lazily, though. Watch the print calls here:
def is_negative(n):
print(f" checking {n}")
return n < 0
readings = [12, 7, -3, 40, 18]
print("generator:")
print(any(is_negative(n) for n in readings))
print("list comprehension:")
print(any([is_negative(n) for n in readings]))
Output:
generator:
checking 12
checking 7
checking -3
True
list comprehension:
checking 12
checking 7
checking -3
checking 40
checking 18
True

Square brackets build the whole list first, so every function call runs. I always drop the brackets and pass a generator. If you use list comprehensions in Python a lot, this is the one spot where the bracket-free version is clearly better.
Use Python any() with strings and dictionaries
A string is an iterable of characters, so any() handles character checks well. A dictionary iterates over its keys, which surprises a lot of people:
password = "Spring2026"
print("Has a digit:", any(ch.isdigit() for ch in password))
print("Has a symbol:", any(not ch.isalnum() for ch in password))
stock = {"apples": 0, "pears": 0, "plums": 4}
print("any(stock): ", any(stock)) # checks the KEYS
print("any(stock.values()):", any(stock.values())) # checks the counts
flags = {0: "off", "": "blank"}
print("any(flags):", any(flags)) # both keys are falsy
Output:
Has a digit: True
Has a symbol: False
any(stock): True
any(stock.values()): True
any(flags): False

any(stock) is True because the keys are non-empty strings, while stock.values() is True only because plums has 4.For the counts, pass .values(). Character tests like isdigit() are covered in the isdigit() method in Python, and key lookups in checking if a Python dictionary contains a key.
Python any() vs all() and the or operator
any() is a chained or over an iterable, and all() is a chained and. The difference shows most on empty input:
| Expression | Returns True when | Empty input |
|---|---|---|
any(items) | at least one item is truthy | False |
all(items) | every item is truthy | True |
a or b or c | one of a fixed set of values is truthy | n/a |
Use or for a few known values and any() when the count isn’t fixed. Testing that every item passes is covered in the Python all() function. When the question is really “is this empty?”, see checking if a variable is null or empty in Python.
A few related checks build on the same idea:
- Check if any list element is in another list
- Check a string for special characters
- Python map() function
- Convert a string to a boolean in Python
Frequently asked questions
What does any() return for an empty list?
False. With no items, nothing can be truthy.
What’s the difference between any() and all() in Python?
any() needs one truthy item; all() needs every item truthy and returns True for an empty iterable.
Does any() check dictionary keys or values?
Keys. Use any(d.values()) to test the values.
Is any() faster than a for loop?
It does the same early-exit work in C, so it’s usually as fast or faster and shorter to read.
How do I get the item that made any() return True?
Use next((x for x in items if test(x)), None), which returns the first match or None.
Where is any() documented?
See any() in the Python docs.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn