Javatpoint Logo
Javatpoint Logo

Python any() Method

Python any() method is used to check whether any value in the iterable is True or not. It takes an iterable argument like list, string, tuple etc. It returns True if any element of the iterable is true and False if the iterable is empty.

Signature

Parameters

iterable: List of iterable elements.

Return

It returns boolean either True or False.

Let's see some examples of any() method to understand it's functionality.

Python any() Method Example 1

This is a simple example which checks whether the list is has any true (or non zero) value. If it founds any value true, returns True. See the example below.

Output:

True

Python any() Method Example 2

If the iterable value is empty, it returns False. See an example below.

Output:

False

Python any() Method Example 3

Output:

True
True
False
True
False

Python any() Method Example 4

This method can be called on string. List, tuple etc. See an example below.

Output:

True
False
True

Next TopicPython Functions




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA