Built-in Functions
all()
Check whether every item in an iterable is truthy.
all(iterable)
all() returns True if every element in the given iterable evaluates to truthy (or if the iterable is empty).
It short-circuits and returns False as soon as the first falsy element is encountered.
Arguments
Parameters
| Name | Description |
|---|---|
| iterable | A collection or other iterable of values to check. |
Result
Returns
True if every item is truthy; otherwise False.
Run it
Try it
Run it and change it
answers = [True, 1, "yes"] print(all(answers))
Output
Press Run to see what it prints.Worth knowing
- Vacuously True on empty iterables:
all([])andall({})returnTrue.