try, except, or else!

We'll cover the following...

The try/except statement also has an else clause. The else will only run if there are no errors raised. We will spend a few moments looking at a couple examples:

Press + to interact
my_dict = {"a":1, "b":2, "c":3}
try:
value = my_dict["a"]
except KeyError:
print("A KeyError occurred!")
else:
print("No error occurred!")

Here we have a dictionary with 3 elements and in the ...