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