When something goes wrong, Python throws an exception. For example, trying to divide a number by 0 won't work. If the exception is not handled, it will end the execution.
In the next simple example, Python will print the string before the division, then it will throw an exception, printing it to the standard error, which happens to be the screen by default, and then nothing. The script stops working and the string "after" is not printed.
from __future__ import print_function def div(a, b): print("before") print(a/b) print("after") div(1, 0) # before # Traceback (most recent call last): # File "examples/exceptions/divide_by_zero.py", line 8, in <module> # div(1, 0) # File "examples/exceptions/divide_by_zero.py", line 5, in div # print(a/b) # ZeroDivisionError: integer division or modulo by zero