Python-any function and all function

Source: Internet
Author: User

Any function:

Any (x), as long as one of the x is not empty, 0,false returns True, otherwise false

All (x) function

All elements in x must not be empty, 0,false will return true, otherwise false

>>> any ('123') True>>> any ([0,1]) True>>> any ([0,'0',"']) True>>> any ([0,"']) False>>> any ([0,"','false']) True>>> any ([0,"', BOOL ('false')]) True>>> any ([0,"', False]) False>>> any ('a','b','C')) True>>> any ('a','b',"')) True>>> any (0,false,"')) False>>>Any ([]) False>>>Any (()) False>>> All (['a','b','C','D'])#Lists list,True>>> All (['a','b','C','D'])#list, elements are not empty or 0True>>> All (['a','b',"','D'])#List of lists, there is an empty elementFalse>>> all ([0, 1, 2, 3])#List of lists, there is an element of 0False>>> All ('a','b','C','D'))#tuples tuple, elements are not empty or 0True>>> All ('a','b',"','D'))#tuples tuple, there is an empty elementFalse>>> All ((0, 1, 2, 3))#tuples tuple, there is an element of 0False>>> all ([])#Empty listTrue>>> All (())#Empty tupleTrue>>>#Note: Empty tuple, empty list return value is true, here is to pay special attention to>>> All ("',"',"',"'))#tuples tuple, all empty elementsFalse>>> All ("') True>>>#returns True if all elements of all (x) parameter x are not 0, ', false, or x is an empty object, otherwise false>>>

[1]. http://www.cnblogs.com/apple2016/p/5767453.html

Python-any function and all function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.