Site icon i2tutorials

Any() method in Python Built in Function

Any() method in Python Built in Function

 

any method in built function returns the absolute value as TRUE if any one of the item is true in the argument.

 

Syntax:

any(iterable)

 

Table of any method

WhenValue
All values are trueTrue
All values are falseFalse
Only one value is TrueTrue
Only one value is FalseTrue
Only IterableFalse

           

Example-1:

 

When all values are TRUE

text = [True, True, True]
x = any(text)
print(x)

 

Output:

 

Example-2:

 

When all values are FALSE

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

 

Output:

 

Example-3:

 

When only one value is TRUE

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

 

Output:

 

Example-4:

 

When only value is FALSE

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

 

Output:

 

Example-5:

 

When the Iterable is empty

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

 

Output:

Exit mobile version