Built-in Functions and Types

any()

Check whether at least one item passes truth testing. Return immediately when a true item is encountered; an empty iterable fails because there is no matching item. A one-pass iterator may be partly consumed. Unlike the or operator, the result is always a Boolean rather than the winning operand.

Formal Syntax & Structure

python syntaxpython
any(iterable, /)

Parameters & Attributes

NameTypeDescription
iterableiterableItems to test for truthiness.

Return Value

bool

Boolean result of the truth test across the iterable.

Working Example

Example Snippetpython
alerts = [0, 0, 2]print(any(alerts))print(any([]))
Python Reference