Python all() ফাংশন
Instance
Check if all items in the list are True:
mylist = [True, True, True] x = all(mylist)
Definition and Usage
If all items in the iterable are true, the all() function returns True, otherwise it returns False.
If the iterable is empty, the all() function also returns True.
Syntax
all(iterable)
Parameter Value
Parameter | Description |
---|---|
iterable | Iterables (lists, tuples, dictionaries) |
More Examples
Instance
Check if all items in the list are True:
mylist = [0, 1, 1] x = all(mylist)
Instance
Check if all items in the tuple are True:
mytuple = (0, True, False) x = all(mytuple)
Instance
Check if all items in the set are True:
myset = {0, 1, 0} x = all(myset)
Instance
Check if all items in the dictionary are True:
mydict = {0 : "Apple", 1 : "Orange"} x = all(mydict)
Note:When used in a dictionary, the all() function checks all keys as true, not values.
Related Pages
Reference Manual:any() Function