any()

The any() built-in function takes in an iterable object such as a list or tuple and returns True if any of the elements in the iterable are true. If none of the elements present in the iterable are true, any() will return False.

Syntax

Loading...

Example 1

Use any() to check if there is a True statement in a list [True, 0, False]:

Loading...

Example 2

Use any() to check if there is a True statement in a dictionary:

Loading...

The Function

The any() built-in function is essentially:

Loading...

Codebyte Example

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy