![]() |
VOOZH | about |
The Python all() function returns true if all the elements of a given iterable (List, Dictionary, Tuple, set, etc.) are True otherwise it returns False. It also returns True if the iterable object is empty. Sometimes while working on some code if we want to ensure that user has not entered a False value then we use the all() function.
Syntax: all( iterable )
- Iterable: It is an iterable object such as a dictionary,tuple,list,set,etc.
Returns: boolean
Output:
False
Here we are considering list as a iterable.
True False False True False
Here we are considering a tuple as a iterable.
True False False True True
Here sets are referred to as iterables
True False False True True
Here we are considering dictionaries as iterables.
True False False True False
Note: In the case of a dictionary if all the keys of the dictionary are true or the dictionary is empty the all() returns True, else it returns False.
True True True