import math try: #This will raise a TypeError print( 3 + 'hello' ) #This will raise a ValueError math.sqrt(-16) #This will raise a NameError print(a) #This will raise a zeroDivisionError print(10 / 0) except NameError: print("A NameError occurred") except ValueError: print("A ValueError occurred") except ZeroDivisionError: print("A ZeroDivisionError occurred") except TypeError: print("A TypeError occurred")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter