Check if all items in a list are True:
mylist = [True, True, True]
x = all(mylist)
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.
Check if all items in a list are True:
mylist = [0, 1, 1]
x = all(mylist)
Check if all items in a tuple are True:
mytuple = (0, True, False)
x = all(mytuple)
Check if all items in a set are True:
myset = {0, 1, 0}
x = all(myset)
Check if all items in a dictionary are True:
mydict = {0 : "Apple", 1 : "Orange"}
x = all(mydict)
Note: When used on a dictionary, the all() function checks if all the keys are true, not the values.
Related PagesTrack your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4