Python all()

Configurare noua (How To)

Situatie

The all() function returns True if all elements in the given iterable are true. If not, it returns False.

Solutie

Pasi de urmat

# all values true
l = [1, 3, 4, 5]
print(all(l))

# all values false
l = [0, False]
print(all(l))

# one false value
l = [1, 3, 4, 0]
print(all(l))

# one true value
l = [0, False, 5]
print(all(l))

# empty iterable
l = []
print(all(l))

Output:

True
False
False
False
True

Tip solutie

Permanent

Voteaza

(5 din 15 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?