Python - 23

Python - 23: Error Handling With Try & Except

Programs can crash when errors happen. try and except help prevent crashes.

✦ Python Editor
▶ Output

👀 Show Example Solution
try:

    age = int(input("Enter your age: "))

    print("Age saved!")

except:

    print("Please enter numbers only!")

try:

    result = 50 / 0

except:

    print("Math error detected!")