What does all mean in Python?

Better Stack Team
Updated on February 3, 2023

In Python, the all() function returns True if all elements of an iterable (e.g. list, tuple, etc.) are true, and False otherwise. For example:

>>> all([True, True, True])
>>> all([True, False, True])

An empty iterable returns True.

>>> all([])

It can also be used on a generator object.

>>> all(i > 2 for i in [1, 2, 3, 4])

It is equivalent to the following code:

>>> def all(iterable):
...     for element in iterable:
...         if not element:
...             return False
...     return True
Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →