all() in Python


Python tip:

You can use all to check whether all values inside an iterable are truthy.

👇

numbers = [10, 99, 321, 3]
print(all(number > 0 for number in numbers))
# => True

print(all([]))
# => True

numbers = [-1, 2, 5, 10, 0]
print(all(number > 0 for number in numbers))
# => False