any

Full name
any
Library
Built-in
Syntax

any(iterable)

Description

The any function returns the boolean True if any of the elements of the iterable that is passed as an argument is True, and returns the boolean False otherwise (or if the iterable is empty).

This function is equivalent to:

def any(iterable):

    for element in iterable:

        if element:

            return True

    return False

Parameters
  • iterable: iterable to analyze.
Examples

If, for example, the iterable is a list, the function will return True only when any of the elements in the list is True:

Any function. Example of use

 

If it is an empty list, the function returns False:

Any function. Example of use
Submitted by admin on Sat, 01/19/2019 - 23:44