There come situations in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations arise in programming also where we need to make some decisions and based on these decisions we will execute the next block of code. This is done with the help of decision-making statements in Python.
i is greater than 15 i'm in else Block i'm not in if and not in else Block
We can have an if…elif…else statement inside another if…elif…else statement. This is called nesting in computer programming. Any number of these statements can be nested inside one another. Indentation is the only way to figure out the level of nesting. This can get confusing, so it must be avoided if we can.
if (condition1): # Executes when condition1 is true if (condition2): # Executes when condition2 is true # if Block is end here # if Block is end here
i is smaller than 15 i is greater than 12 and smaller than 15
- with statement in Python
- Python Continue Statement
- Python return statement
- Python break statement
- Python pass Statement
- Using else conditional statement with for loop in python
- Statement, Indentation and Comment in Python
- Check multiple conditions in if statement - Python
- How to write an empty function in Python - pass statement?
- Python - Read blob object in python using wand library
- Reading Python File-Like Objects from C | Python
- Python | Convert list to Python array
- twitter-text-python (ttp) module - Python
- Python | PRAW - Python Reddit API Wrapper
- MySQL-Connector-Python module in Python
- Important differences between Python 2.x and Python 3.x with examples
- Python | Index of Non-Zero elements in Python list
- Python | Merge Python key values to list
- Python | Add Logging to Python Libraries
- Python | Sort Python Dictionaries by Key or Value
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.