Python all() Function
The python all() function accepts an iterable object (such as list,dictionary etc.). It returns True if all items in passed iterable are true, otherwise it returns False. If the iterable object is empty, the all() function returns True.
Signature
Parameters
- iterable - The objects which contain the elements i.e. list, tuple and dictionary, etc.
Return
- True - If all the elements in an iterable are true.
- False - If all the elements in an iterable are false..
Python all() Function Example 1
Let's see how all() works for lists?
Output:
True False False False True
Python all() Function Example 2
The below example shows how all() works for dictionaries.
Output:
True False False True True
Python all() Function Example 3
The below example shows how all() works for tuples.
Output:
True False False False
0 comments:
Post a Comment
Thanks