Nesting Conditional Statements

--Originally published at Python

Nesting conditional statements refers to the process of writing a conditional statement inside of another. For example, if we were to use “if” we could write another “if” inside of it but with a more specific condition. It’s like having several filters in order to see which condition is true. And depending on that condition, a specific process will be done. Here’s an example:

Code:

num = int(input(“Type a number: “))

if num<=0:
if num<=-10:
if num<-100:
print(“Your number is smaller than -100”)
else:
print(“Your number is between -10 and -100”)
else:
print(“Your number is between 0 and -10”)
else:
print(“Your number is bigger than 0”)

2nesting