Catching the Exceptions
We'll cover the following...
Let’s see if you have been practicing your catching correctly.
⚠️ The following code is meant for Python 2.x versions.
Press + to interact
some_list = [1, 2, 3]try:# This should raise an ``IndexError``print(some_list[4])except IndexError, ValueError:print("Caught!")try:# This should raise a ``ValueError``some_list.remove(4)except IndexError, ValueError:print("Caught again!")
...