all Python 3Built-in functionsterm
all
logic
Returns True if all elements of the iterable are true, or if the iterable is empty. Evaluates lazily.
Syntax
all(iterable)
Truthiness goes through bool(), which is not the same as «the value is present»: a zero among numbers or an empty string among strings turns the check into False even though nothing is missing, so spell the condition out with is not None when presence is what you mean. Mind the negation too: not all(...) says «at least one is false», not «all are false» — the latter needs any() over the negated condition.
Examples
print(all([True,True,True])) # → True
print(all([True,False,True])) # → False
print(all([])) # → True (пустой)
print(all(x>0 for x in [1,2,3])) # → True
print(all(x>0 for x in [1,-1,3])) # → False
See also
Open in the full glossarydocs.python.orgReport an inaccuracy