The all()
function is one of Python's built-in functions. It takes an iterable as input and returns True
if all elements in the iterable are truthy (non-zero, non-empty, not None
, etc.), otherwise it returns False
.
Example Code
a = [1, 2, 3]
b = [0, 1, 2]
c = [True, False, True]
print(all(a)) # Output: True, because all elements in a are non-zero and truthy
print(all(b)) # Output: False, because the first element in b is 0, which is falsy
print(all(c)) # Output: False, because the second element in c is False, which is falsy