demo_try_except2.py:
#The try block will generate a NameError, because x is not defined: try: print(x) except NameError: print("Variable x is not defined") except: print("Something else went wrong")
➜ begtut>python demo_try_except2.py
Variable x is not defined