If you create if-else statements inside other if-else statements, we will call it as nested if-else statements in python. The nested if-else statements are useful when you want to execute the block of code/statements inside other if-else statements.
To know more about specifying the indentation in python, refer Python basic syntaxes.
Following is the flow chart diagram of the nested if-else statements process flow in python.
Following is the example of a nested if-else statement in python to execute the required block of statements based on the defined Boolean expression.
x = 30
y = 10
if x >= y:
print("x is greater than or equals to y")
if x == y:
print("x is equals to y")
print("x is greater than y")
print("x is less than y")
When you execute the above python program, you will get the result like as shown below.
x is greater than or equals to y
x is greater than y
This is how you can create nested if-else statements in python to execute the block of statements based on your requirements.