FREE E LEARNING PLATFORM
HOMEEXCEPTIONSOOPSJVMINTRO
 

Nested If else statement




When there is an if statement (or if..else or if..elif..else) is present inside another if statement (or if..else or if..elif..else) then this is calling the nesting of control statements.

Nested if..else statement example

Here we have a if statement inside another if..else statement block. Nesting control statements makes us to check multiple conditions.

num = -99
if num > 0:
    print("Positive Number")
else:
    print("Negative Number")
    #nested if
    if -99<=num:
        print("Two digit Negative Number")

Output

Negative Number
Two digit Negative Number







Leave Comment