Python any and all function

Source: Internet
Author: User
Tags iterable

1 any

Returns True if the Iterable object has at least one element that is true. The empty Iterable object returns to False.

2 All

Returns true if every element in the Iterable object is true, and the empty Iterable object also returns True.

3 What is called Iterable the element of object is True

All of Python's objects have true and false. The object that satisfies the following conditions is false, and the rest is true.

  • None

  • False

  • Zero of any numeric type, for example,,,, 0 0L 0.0 0j .

  • Any empty sequence, for example,,,, ‘‘ () [] .

  • Any empty mapping, for example, {} .

  • Instances of user-defined classes, if the class defines a __nonzero__() or __len__() method, when that method returns the integer zero or bool value False . [1]

Python any 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.