A nested if is an if that has another if in its if’s body or elif’s body or else’s body.
syntax:-
if expression1: statement(s) if expression2: statement(s) else: statement(s) else: statement(s)
e.g.,
n = 5 if n >= 0: if n == 0: print("Zero") else: print("Positive number") else: print("Negative number")
Output- positive number
This is how we use nested if statement in python.