Python Try Except
try block lets you test a
block of code for errors.
except block lets you
handle the error.
finally block lets you
execute code, regardless of the result of the try- and except blocks.
You can define as many exception blocks as you want, e.g. if you want to execute a special block of code for a special kind of error:
Print one message if the try block raises a
NameError and another
for other errors:
print("Variable x is not defined")
print("Something else went wrong")