A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3schools.com/python/ref_func_any.asp below:

Website Navigation


Python any() Function

Python any() Function

❮ Built-in Functions

Example

Check if any of the items in a list are True:

mylist = [False, True, False]
x = any(mylist)

Try it Yourself » Definition and Usage

The any() function returns True if any item in an iterable are true, otherwise it returns False.

If the iterable object is empty, the any() function will return False.

Syntax Parameter Values Parameter Description iterable An iterable object (list, tuple, dictionary) More Examples Example

Check if any item in a tuple is True:

mytuple = (0, 1, False)
x = any(mytuple)

Try it Yourself » Example

Check if any item in a set is True:

myset = {0, 1, 0}
x = any(myset)

Try it Yourself » Example

Check if any item in a dictionary is True:

mydict = {0 : "Apple", 1 : "Orange"}
x = any(mydict)

Try it Yourself »

Note: When used on a dictionary, the any() function checks if any of the keys are true, not the values.

Related Pages

The all() Function

❮ Built-in Functions

Track your progress - it's free!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4