Let's assume, a code consists of nearly 50 lines, and it has a try
block. Consider a case that the try
block has 10 unknown errors. Is it possible to handle those exceptions without specifying the name of the error in the except
clause?
Here is the sample code:
try:
a = 2
b = 2 / 0
if 7 > 5:
print(7)
except(ZeroDivisionError, IndentationError)
print("Exception Handled")
In the above case, I know the name of the errors that occurred in the try block(say- ZeroDivisionError
and IndentationError
)
What if the name of the error is unknown?
No comments:
Post a Comment