Python any() Function
Python any() Function
The any() function in Python returns a boolean value ‘True’ if any element of the iterable is true or if the iterable is empty, else it returns False.
Syntax
any(iterable)
Parameter
Iterable: An iterable object (list, tuple, dictionary)
Return
This function returns a Boolean value True if any element of the iterable is true or if the iterable is empty, else it returns False.
Example 1
# Python Program explaining # any() built-in function # Since, all the iterables are false, false is returned print ('The any() function will return: ',any([False, False, False, False])) # item (True) and will return True. print ('The any() function will return: ',any([False, True, False, False, False, True])) # first iterable is True and will return True. print ('The any() function will return: ',any([True, False, False, False, True]))
Output
The any() function will return: False The any() function will return: True The any() function will return: True