Look at the following code and the output traceback. Pay attention to the fact that we are not raising any exception explicitly with a raise statement, but we cause it implicitly (BTW: dividing by 0 is always a good way to cause an exception or error in most of the programming languages):
Traceback (most recent call last):
File "exceptions#030.py", line 6, in <module>
print(a_list[3])
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "exceptions#030.py", line 8, in <module>
print(1 / 0)
ZeroDivisionError: division by zero
output
The result of the code execution contains a message that joins the subsequent tracebacks:
During handling of the above exception, another exception occurred:
It contains an interesting piece of information indicating that we’ve just witnessed a chain of exceptions.