all(iterable)
where iterable is the object that needs to be checked for truthiness.
Example
>>> all([True, True, True])
True
>>> all([True, False, True])
False
>>> all([1, 3, 4, 5]) # All numbers are considered True in Python
True
If the iterable is empty, the function returns True.
Example
>>> all([])
True
You can also use the all() function with a generator expression or a list comprehension.
Example
>>> all(i > 5 for i in [6, 7, 8])
True
>>> all(i > 5 for i in [6, 7, 3])
False
Younes Derfoufi
my-courses.net
my-courses.net
No comments:
Post a Comment