Python all() function
Published February 14, 2022The all() function is a Python built-in function that returns true if all the items of a specified iterable are true and returns false if they are not. If the iterable objects are also empty, then the function returns true as well.
The Syntax
The following is the syntax of implementing the all() function:
All(iterable) |
Where: an iterable object is an object including a set, list, tuple, or dictionary.
Example
The following example shows how the all() Python function works
a = (5,7,9) print(all(a)) a = (0, False, False) print(all(a)) a = (5, 3, 0, 1, False) print(all(a)) a = () print(all(a)) |
Output
If you run the code above, the following will be output.
Article Contributed By :
|
|
|
|
245 Views |