Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

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.xPython 3.x
Introduced in 2.5Yes

 

all() Function Examples

 

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


Return value: True

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


Return value: True

Example: When Empty iterable in all()


Output: True

 

Loading...
LearnAndLearn.com © 2018 - All rights reserved