all() function is used to check the nature iterables within the function. Below is the formula for the same.
- all() returns as FALSE ==> If any one of the Input's list is FALSE or Zero.
- all() returns as TRUE ==> If all the Input value in the list is Empty
- 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)