This page topics close

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)

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

What next?

The next topic is Python for Loop Statements

Share this page