Raising Error According to Condition in Try Block || Try and Except || Exception Handling || Python
 

In this, we are going to see an example on Raising Error According to Condition in Try Block that is done using Exception Handling in Python Programming Language.

# NOTE: Enter a string with length greater than 6 to run the except block condition

print("String length should be less than 6")

try:
    s = input()
    if len(s) > 6:
        raise()
    print(s)
except Exception:
    print("Limit exceeds")

# 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