VOOZH about

URL: https://www.geeksforgeeks.org/python/python-all-function/

⇱ Python - all() function - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python - all() function

Last Updated : 23 Jul, 2025

The Python all() function returns true if all the elements of a given iterable (List, Dictionary, Tuple, set, etc.) are True otherwise it returns False. It also returns True if the iterable object is empty. Sometimes while working on some code if we want to ensure that user has not entered a False value then we use the all() function.

Python all() Function in Python

Syntax: all( iterable )

  • Iterable: It is an iterable object such as a dictionary,tuple,list,set,etc.

Returns: boolean

Python all() Function with Example

Output:

False

Example 1: Working of all() with Lists

Here we are considering list as a iterable.


Output
True
False
False
True
False

Example 2: Working of all() with Tuples

Here we are considering a tuple as a iterable.


Output
True
False
False
True
True

Example 3: Working of all() with Sets

Here sets are referred to as iterables


Output
True
False
False
True
True

Example 4: Working of all() with Dictionaries

Here we are considering dictionaries as iterables.


Output
True
False
False
True
False

Note: In the case of a dictionary if all the keys of the dictionary are true or the dictionary is empty the all() returns True, else it returns False.

Example 5: Working of all() with Strings


Output
True
True
True
Comment
Article Tags: