How to use the any function in python
This article mainly introduces "how to use any function in python". In daily operation, I believe many people have doubts about how to use any function in python. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts of "how to use any function in python"! Next, please follow the small series to learn together!
Specific example analysis:
>>>any(['a', 'b',' c','d']) #list, none of the elements is empty or 0
True
>>> any(['a',' b','d']) #list, there is an empty element
True
>>> any([0,'', False]) #list, elements are all 0,'',false
False
>>> any(('a ', ' b','c',' d')) #tuple tuple, none of the elements is empty or 0
True
>>> any(('a ', ' b','d')) #tuple tuple, there is an empty element
True
>>> any((0,'', False)) #tuple tuple, all elements are 0,'',false
False
>>> any([]) #Empty list
False
>>> any(()) #empty tuple
False
Note: If the return value is empty, 0, false, then return false, if not empty, 0, false, then return true.
At this point, the study of "how to use any function in python" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!