In this tutorial, you will learn about the Python any() function with the help of examples.
any() function returns True if any item in an iterable is true, otherwise, it returns False. If the iterable object is empty, the
any() function will return False, opposite to all() function.
The syntax of the
any() function looks like this:
Where an iterable object may be a list, tuple, or dictionary.
# Check if all items in a list are True mylist = [0, 1, 1] x = all(mylist) print(x) # Returns True because the second item is True # Check if all items in a tuple are True: mytuple = (0, True, False) x = all(mytuple) print(x) # Returns True because the second item is True
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.