#Using the any() Function
print(any([1, 0, 0]))
print(any([0, 0, 0]))
The any(
) function checks if there is any value in a given iterable with a boolean value of True
.
The function takes an iterable such as list, tuple, dictionary etc. as the only argument.
any(iterable)
iterable |
The iterable containing elements to be checked. |
The function returns a boolean value. True
if there is an element in with a boolean value of True
, False
if all the elements have a boolean value of False
.
Examples:
any([0, 1, 2, 3])
//True
any(['', [], 0])
//False
any([0, 0, 0, 0])
//False
any((False, False, False))
//False