Python any() function
Instance
Check if any item in the list is True:
mylist = [False, True, False] x = any(mylist)
Definition and usage
If any item in the iterable is true, the any() function returns True, otherwise it returns False.
If the iterable is empty, the any() function will return False.
Syntax
any(iterable)
Parameter value
Parameter | Description |
---|---|
iterable | Iterable objects (list, tuple, dictionary) |
More examples
Instance
Check if any item in the tuple is True:
mytuple = (0, 1, False) x = any(mytuple)
Instance
Check if any item in the set is True:
myset = {0, 1, 0} x = any(myset)
Instance
Check if any item in the dictionary is True:
mydict = {0 : "Apple", 1 : "Orange"} x = any(mydict)
Komentaryo:Sa paggamit ng diko, ang any() function ay sasusuri kung may anumang key na true, hindi ang halaga.
Related pages
Reference manual:all() function