{"id":24549,"date":"2021-10-21T10:13:05","date_gmt":"2021-10-21T04:43:05","guid":{"rendered":"https:\/\/python-programs.com\/?p=24549"},"modified":"2021-11-05T19:37:25","modified_gmt":"2021-11-05T14:07:25","slug":"python-any-function-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-any-function-with-examples\/","title":{"rendered":"Python any() Function with Examples"},"content":{"rendered":"

In the previous article, we have discussed Python Program for ascii() Function<\/a>
\n any() Function in Python:<\/strong><\/p>\n

The function any() returns True if any of the items in an iterable are true; otherwise, False.<\/p>\n

The any() function returns False if the iterable object is empty.<\/p>\n

Syntax:<\/strong><\/p>\n

any(iterable)<\/pre>\n

Parameters<\/strong><\/p>\n

iterable: <\/strong>It may be any iterable object like list, tuple, dictionary, etc.<\/p>\n

Note:<\/strong> When applied to a dictionary, the any() function determines whether any of the keys are true, rather than the values.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list = []\r\nGiven tuple = (1, 2, 0, 0)\r\nGiven dictionary = {1: 'hello', 2: 'this is', 0: 'btechgeeks'}<\/pre>\n

 <\/p>\n

Output:<\/strong><\/p>\n

The result after applying any() function on the given list =  False\r\nThe result after applying any() function on the given tuple =  True\r\nThe result after applying any() function on the given dictionary =  True<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list =  [0, 1, 0, 1]\r\nGiven tuple = (0, 0, 0)\r\nGiven dictionary = {0: 'good', 0: 'morning'}<\/pre>\n

Output:<\/strong><\/p>\n

The result after applying any() function on the given list =  True\r\nThe result after applying any() function on the given tuple =  False\r\nThe result after applying any() function on the given dictionary =  False<\/pre>\n

Program for any() Function in Python<\/h2>\n