An exception should be caught only once in a try
-except
block.
It is useless to catch the previously caught exception later in other else blocks as the previous exception block handling the exception would be executed every time.
try:
1 / 0
except ZeroDivisionError:
print("Divided by zero")
except (OSError, ZeroDivisionError):
print("Handles an exception which was caught before.")
try:
1 / 0
except ZeroDivisionError:
print("Divided by zero")
except OSError:
print("Handles a unique exception")