Skip to content

any()

The built-in any() function checks if any element in an iterable is true. It returns a Boolean value, True if at least one element is truthy, otherwise False:

Language: Python
>>> any([False, False, True])
True
>>> any([False, False, False])
False

any() Signature

Language: Python Syntax
any(iterable, /)

Arguments

Argument Description
iterable An iterable object whose elements are evaluated for truthiness.

Return Value

  • Returns True if at least one element in the iterable is truthy.
  • Returns False if the iterable is empty or all elements are falsy.

any() Examples

With a list of Boolean values:

Language: Python
>>> any([False, False, True])
True

With a list of integers:

Language: Python
>>> any([0, 0, 1, 0])
True

With a list containing one truthy element:

Language: Python
>>> any(["", 42, {}, 0])
True

With an empty list:

Language: Python
>>> any([])
False

any() Common Use Cases

The most common use cases for the any() function include:

  • Checking if any element in a list satisfies a condition.
  • Validating input where at least one field must be filled or true.
  • Evaluating multiple conditions compactly.

any() Real-World Example

Suppose you need a function to decide whether to send a notification to a user based on multiple criteria like unread messages, pending tasks, or upcoming events:

Language: Python
>>> def should_notify(unread_messages, pending_tasks, upcoming_events):
...     return any([
...         unread_messages > 0,
...         pending_tasks > 0,
...         upcoming_events > 0
...     ])
...

>>> should_notify(0, 0, 0)
False

>>> should_notify(0, 0, 1)
True

In this example, you use any() to determine if any notification criteria are met, allowing you to notify the user accordingly.

Python Pit Stop

Tutorial

How to Use any() in Python

Use any() in Python to check whether at least one condition is true, simplify complex conditionals, and see how it compares to the or operator.

basics python

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Aug. 21, 2026 • Reviewed by Brenda Weleschuk and Dan Bader