Skip to content

#383 Python all() & any() & string.count() & string.ascii_lowercase #3

@LiuL0703

Description

@LiuL0703

all()
Return True if all elements of the iterable are true (or if the iterable is empty).
如果iterable的所有元素为真 , 则all(iterable)返回True,否则返回False;函数等价于:

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

例如:

all(['a', 'b', 'c', 'd'])  # True
all([‘a’,'b','','d'])      #False

any() 则与all()相对
Return True if any element of the iterable is true. If the iterable is empty, return False.
如果iterable的任一元素为true 则返回true

def any(iterable):
    for element in iterable:
        if element:
            return True
    return False
any(['a', 'b', 'c', 'd'])  # True
any(['a','',''])      #True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions