Any and All are two built ins provided in python used for successive And/Or.
Returns true if any of the items is True. It returns False if empty or all are false. Any can be thought of as a sequence of OR operations on the provided iterables.
It short circuit the execution i.e. stop the execution as soon as the result is known.
Syntax : any(list of iterables)
False True True
Returns true if all of the items are True (or if the iterable is empty). All can be thought of as a sequence of AND operations on the provided iterables. It also short circuit the execution i.e. stop the execution as soon as the result is known.
Syntax : all(list of iterables)
True False False
See whether at least one number is divisible by 5 in list 1=> True
See whether all numbers in list1 are odd => True
Truth table :-
This article is contributed by Mayank Rawat .If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Python - Read blob object in python using wand library
- Python | PRAW - Python Reddit API Wrapper
- Important differences between Python 2.x and Python 3.x with examples
- Python | Convert list to Python array
- MySQL-Connector-Python module in Python
- Python | Index of Non-Zero elements in Python list
- twitter-text-python (ttp) module - Python
- Reading Python File-Like Objects from C | Python
- Python | Merge Python key values to list
- Python | Sort Python Dictionaries by Key or Value
- Python | Add Logging to a Python Script
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to Python Libraries
- Python | Visualizing O(n) using Python
- Python vs PHP
- Python Set | pop()
- C Vs Python
- bin() in Python
- zip() in Python
Improved By : pritam_pranjay