Python any() function
Published February 15, 2022If you're writing a Python program, you may want to verify that any or all things may be evaluated to true iteratively. The any () Python function may be used to do this. We'll take a look at how any() Python function works.
How any() Function Works
The syntax for implementing any() functions in Python is as follows.
Any(iterable object) |
Where, an iterable object includes a tuple, dictionary, set, list etc.
If any of the items in an iterable object is True, this function returns true.
Example
b = [ 3, 4, 2] print(any( b )) b = [ 3, 5, 2, 6, False] print(any( b )) b = [ 0, 0, False] print(any( b )) b = [] print(any( b )) |
Output
When you execute the code shown above, you'll see the following:
![]() |
Article Contributed By :
|
|
|
|
268 Views |