Python Nested if else Statement

If with in if is called Nested If.

  In python, we can use nested If Else to check multiple conditions. Python provides elif keyword to make nested If statement.

  In a nested if construct, you can have an if...elif...else construct inside another if...elif...else construct.


Syntax of Nested if

if expression1:
   statement(s)
   if expression2:
      statement(s)
   elif expression3:
      statement(s)
   else:
      statement(s)
   elif expression4:
      statement(s)
else:
   statement(s)


a=10  
if a>=20:  
    print ("Condition is True")  
else:  
    if a>=15:  
        print ("Checking second value")  
    else:  
        print ("Yes , You are here")  
Yes , You are here