Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.
BUILT-IN FUNCTIONS

In this tutorial, you will learn about the Python any() function with the help of examples.

The 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:

any(iterable)

Where an iterable object may be a list, tuple, or dictionary.

Examples:

# 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