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 return statement
- Python break statement
- Python Continue Statement
- Statement, Indentation and Comment in Python
- Using else conditional statement with for loop 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
- Important differences between Python 2.x and Python 3.x with examples
- Python | Convert list to Python array
- Python | PRAW - Python Reddit API Wrapper
- Python | Index of Non-Zero elements in Python list
- Python | Merge Python key values to list
- MySQL-Connector-Python module in Python
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.