I'm now learning how to handle multiple errors in python. While using try-except I want to print every error in try. There are two errors in try but the indexing error occurred first, so the program can't print a message about ZeroDivisionError. How can I print both IndexErrormessage and ZeroDivisionErrormessage?
Below is the code I wrote.
try:
a = [1,2]
print(a[3])
4/0
except ZeroDivisionError as e:
print(e)
except IndexError as e:
print(e)