Site icon i2tutorials

All() method in Python Built in Function

All() method in Python Built in Function

 

all method in built function returns the absolute value as TRUE only if all the items are true in the argument or else the output will be FALSE of a given number in the program.

 

Syntax:

all(iterable)

 

Table of ‘all’ method

WhenValue
All values are trueTrue
All values are falseFalse
Only one value is TrueFalse
Only one value is FalseFalse
Only IterableTrue

           

 

Example-1:

 

When all values are TRUE

text = [True, True, True, 'True']
x = all(text)
print(x)

 

Output:

 

Example-2:

 

When all values are FALSE

text = [False, False, False]
x = all(text)
print(x)

 

Output:

 

Example-3:

 

When only one value is TRUE

text = [False, True, False]
x = all(text)
print(x)

 

Output:

 

Example-4

 

When only one value is FALSE

text = [True, False, True]
x = all(text)
print(x)

 

Output:

 

Example-5:

 

When the iterable is empty

text = []
x = all(text)
print(x)

 

Output:

Exit mobile version