Nested Try Except Block || Try and Except || Exception Handling || Python 

In this, we are going to see an example of nested try except block that is done using Exception Handling in Python Programming Language.

# Enter a as 0 and number b as any negative number to see the except statements

try:
    a = int(input("Enter number a: "))
    if a == 0:
        raise()
    try:
        b = int(input("Enter number b: "))
        if b < 0:
            raise()
        print(a+b)
    except:
        print("Number b cannot be negative")
except:
    print("Number a cannot be 0")

# Coded by Saahil

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post