Python all() function

Published February 14, 2022

The 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.

 

Python All() function example

 

Article Contributed By :
https://www.rrtutors.com/site_assets/profile/assets/img/avataaars.svg

245 Views