For that, we'll wrap the critical part of the code in a try: block. After the try: block you need to provide a list of exception that are caught by this try-block. You could say something like "Try this code and let all the exceptions propagate, except of the ones I listed". As we saw in the previous example, the specific error is called ZeroDivisionError. If the specified exception occurs within the try: block, instead of the script ending, only the try block end and the except: block is executed.

examples/exceptions/divide_by_zero_catch.py
from __future__ import print_function

def div(a, b):
    try:
        print("dividing {:} by {:} is {:}".format(a, values[i], a/values[i]))
    except Exception:
        print("Something is wrong here")
        #pass

a = 100
values = 2, 5, 0, 4

for i in range(0, len(values)):
    div(a, i)

# dividing 100 by 2 is 50
# dividing 100 by 5 is 20
# Something is wrong here
# dividing 100 by 4 is 25