“all” in Python

Configurare noua (How To)

Situatie

“all” returns true if all of the items are True or if the iterable is empty. It returns False if any of the items is false.

Solutie

Pasi de urmat

# Here all the iterables are True so all
# will return True and the same will be printed
print (all([True, True, True, True]))

# Here the method will short-circuit at the
# first item (False) and will return False.
print (all([False, True, True, False]))

# This statement will return False, as no
# True is found in the iterables
print (all([False, False, False])

Output :

True
False
False

Tip solutie

Permanent

Voteaza

(17 din 31 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?