DEV Community

Arun kumar G
Arun kumar G

Posted on

Python - Built-in functions - all()

all() function is used to check the nature iterables within the function. Below is the formula for the same.

  1. all() returns as FALSE ==> If any one of the Input's list is FALSE or Zero.
  2. all() returns as TRUE ==> If all the Input value in the list is Empty
  3. all() returns as TRUE ==> If all the Input value in the list is TRUE

Example"

Code for scenario 1:

x=[1,2,5,0]
all(x)

Output: FALSE ( Bcos the x list contains Zero in it)

Code for scenario 2:

x=[]
all(x)

Output: TRUE (As list is Empty)

Code for scenario 3:

x=[1,5,7,9]
all(x)

Output: TRUE (As the list contains only non-zero (TRUE Values))

Top comments (0)