#Using the all() Function
print(all([1, 2, 3, 4, 5]))
print(all([0, 1, 2, 3, 4, 5]))
The all()
function checks whether all elements in a given iterable have a boolean value of True.
The function takes one argument, an iterable object such as a list, set, tuple etc.
all(iterable)
iterable |
An iterable object containing the elements to be checked |
The function returns a boolean value. True
if all the values in the iterable have a boolean value of T
rue
or the iterable is empty, False
otherwise.
Examples:
all([])
//True
all({})
//True
all([1, 2, 3])
//True
all([0, 1, 2, 3])
//False
all(['Hello', 'Python', 'World'])
//True
all(('Hello', 'Python', 'World', ''))
//False