1try:
2 print("I will try to print this line of code")
3except ERROR_NAME:
4 print("I will print this line of code if error ERROR_NAME is encountered")
1import sys
2try:
3 S = 1/0 #Create Error
4except: # catch *all* exceptions
5 e = sys.exc_info()
6 print(e) # (Exception Type, Exception Value, TraceBack)
7
8############
9# OR #
10############
11try:
12 S = 1/0
13except ZeroDivisionError as e:
14 print(e) # ZeroDivisionError('division by zero')