Python built-in functions daily learning-all ()

Source: Internet
Author: User

All (iterable)

Official documentation explains:

Return True If all elements of the iterable be True (or if the iterable is empty). Equivalent to:

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

Detailed

Returns true if the element in Iterable is 0, ', False,all (iterable) returns False

Attention:

Null tuple, empty list return value is True

Instance:

1 Print(All ([1,2,3,4,5]))#True2 Print(All (['a',"','C', 3,4]))#False3 Print(All ([1,0,2,3,4]))#False4 Print(All ('a','b','C','D','e')))#True5 Print(All ('a',"','C','D','e')))#False6 Print(All ('a','b', 0,'D','e')))#False7 Print(All ([]))#True8 Print(All (()))#True9 Print(All ([false,1,2,3]))#False

Python built-in functions daily learning-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.