Python - Exception Handling Fundamentals
What is the issue with this exception handling code?
try:
result = 10 / 0
except:
print('General exception caught')
except ZeroDivisionError:
print('ZeroDivisionError caught')What is the issue with this exception handling code?
try:
result = 10 / 0
except:
print('General exception caught')
except ZeroDivisionError:
print('ZeroDivisionError caught')except: block is first, so it catches all exceptions, making the specific block unreachable.except ZeroDivisionError: block before the general except: block.except block should come after the specific ZeroDivisionError block. is correct.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions