Function Details: any

Description


Returns True if any element of the iterable is true. If the iterable is empty, return False.


Extended Description


The any() function returns True if any element in the given iterable is true. If the iterable is empty, it returns False. It's equivalent to using the or operator between all elements in the iterable. The function short-circuits; it stops iterating as soon as it finds a true value.


Exceptions


  • TypeError: If the argument is not iterable

Read More about any from Python Documentation

Function Signature


any(iterable: Iterable) -> bool

Module: builtins

Parameters


This function takes one parameter: iterable (an Iterable object). This can be any iterable such as a list, tuple, set, or generator.


Parameter List


  • iterable: Iterable

Return


Returns a boolean value. True if any element is true, False if all are false or if the iterable is empty.


Return Type


bool

Output

Explanation

This example shows how any() behaves with different types of iterables, including an empty iterable.