“any” in Python

Configurare noua (How To)

Situatie

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

Solutie

Pasi de urmat

# Since all are false, false is returned
print (any([False, False, False, False]))

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

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

Output :
False
True
True

Tip solutie

Permanent

Voteaza

(6 din 12 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?