Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

In this tutorial, you will learn about the Python all() function with the help of examples.

The all() function returns True if all items in an iterable are true, otherwise, it returns False. If the iterable object is empty, the all() function also returns True.

The syntax of the all() function looks like this:


Where an iterable object may be a list, tuple, or dictionary.


# Check if all items in a list are True
mylist = [0, 1, 1]
x = all(mylist)
# Returns False because 0 is the same as False

# Check if all items in a tuple are True:
mytuple = (0, True, False)
x = all(mytuple)
# Returns False because both the first and the third items are False