What is the function of the any () function in Python
This article shows you what the function of the any () function in Python is. The content is concise and easy to understand. It can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Description
The any () function is used to determine whether the given iterable parameter iterable is all False, returns False, and returns True if one is True.
Elements are TRUE except for 0, null, and FALSE.
Function is equivalent to:
Def any (iterable): for element in iterable: if element: return True return False
Python version 2.5 or later is available.
Grammar
The following is the syntax of the any () method:
Any (iterable) parameter
Iterable-- tuple or list.
Return value
Returns false if all are empty, 0, false, and true if not all empty, 0, false.
Example
The following shows an example of using the any () method:
Description
The any () function is used to determine whether the given iterable parameter iterable is all False, returns False, and returns True if one is True.
Elements are TRUE except for 0, null, and FALSE.
Function is equivalent to:
Def any (iterable): for element in iterable: if element: return True return False
Python version 2.5 or later is available.
Grammar
The following is the syntax of the any () method:
Any (iterable) parameter
Iterable-- tuple or list.
Return value
Returns false if all are empty, 0, false, and true if not all empty, 0, false.
> any (['axed,' baked, 'cased,' d']) # list list, none of the elements are empty or 0True > any (['axed,' baked,'','d']) # list list There is an empty element True > > any ([0grammar, False]) # list list, all of which are 0 tuple tuple ('axie,' baked, 'cased,' d')) # tuple, and none of the elements are empty or 0True > tuple ('axie,' baked,'','d') # tuple There is an empty element True > any ((0gramme, False)) # tuple tuple, and the elements are all 0Zhenzhengjingjie false false > > any ([]) # empty list False > any (()) # empty tuple False. What is the function of the any () function in Python? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.