Definition
The all() function returns True
if all items in an iterable are true, otherwise it returns False
.
If the iterable object is empty, the all() function also returns True
.
Syntax
all(iterable)
Parameters
Parameter | Description |
---|---|
iterable | An iterable object. Could be a list, tuple or dictionary) |
Examples
List
myIntegers = [9, 1, 1]
result = all(myIntegers)
print(result)
Tuple
myTuple = (0, False, False)
result = all(myTuple)
print(result)
Dictionary
cars = {0 : "Nissan", 1 : "Volkswagen"}
result = all(cars)
print(result)