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.
Parameters
| Name | Description |
|---|---|
| iterable | A collection or other iterable of values to check. |
Returns
True if every item is truthy; otherwise False.
Try it
Run it and change it
answers = [True, 1, "yes"] print(all(answers))
Worth knowing
- Vacuously True on empty iterables:
all([])andall({})returnTrue.