Python all() Function

all() is a built-in function in python programming language which gives True in return if all elements of an iterable are true (exists) or empty. All sequence types in Python are examples of iterable. An example of sequence types in Python:

  1. Lists
  2. String
  3. Tuple


all() function is a part of Python Built-in Functions (check list)

all() Syntax

all( iterable )


all() Parameters

iterable – where iterable is a variable representing lists.


all() Return Value

all() function returns a True if elements of iterable is a true (exists) or empty


all() Compatibility

This function is available and compatible with both Python 2.x and 3.x

Python 2.x Python 3.x
Introduced in 2.5 Yes


all() Function Examples


Example: When elements (Number) in iterable are true in all()

MyList = [1,2,3,4,5,6]

Return value: True

Example: When elements(string) in iterable are true in all()

MyStringList = ['a', 'b' , 'c']

Return value: True

Example: When Empty iterable in all()

MyEmptyiterable = []

Output: True