Python function-all ()

Source: Internet
Author: User

All (iterable)

Role:

If all elements of iterable are not 0, ', false, or iterable are empty, all (iterable) returns true, otherwise false; the function is equivalent to:

1 def all (iterable): 2      for inch iterable: 3         if  not element: 4             return False 5     return True

Parameter iterable: an iterative object;

Instance:

1>>> All (['a','b','C','D'])#list, elements are not empty or 02 True3>>> All (['a','b',"','D'])#List of lists, there is an empty element4 False5>>> all ([0, 1, 2, 3])#List of lists, there is an element of 06 False7   8>>> All ('a','b','C','D'))#tuples tuple, elements are not empty or 09 TrueTen>>> All ('a','b',"','D'))#tuples tuple, There is an empty element one False a>>> all ((0, 1, 2, 3))#tuples tuple, There is an element of 0 - False -    the    ->>> All ([])#Empty list - True ->>> All (())#Empty tuple +True

Note: empty tuple, empty list return value is true, here is to pay special attention to

Version: This function appears for the first time in the python2.5 version, and is suitable for 2.5 or more versions, including python3, compatible with the Python3 Version.

Python function-all ()

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.