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))


Discover more from Coursity

Subscribe to get the latest posts sent to your email.

Leave a Comment

Your email address will not be published. Required fields are marked *

Discover more from Coursity

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top
Learn tips on preventing hacking of smart home devices with our expert cybersecurity advice. Free 2025 jamb questions and answers cbt answers jamb / jamb 2025 answers cbt answers jamb. Copyright 2024 — life skills.