0
Is There a way to catch each exception by its name using only one except
Say i Write following code: print("Hello World) print("a"+2) a = b+2 print(a) the above code has 3 error, is it possible to use only one except block? and it automatically detect the name of the other exception after solving previous one?
4 odpowiedzi
+ 1
refer to exception type handler in my codes
0
I say no because once it finds first exception it will come out of try block, so you can handle first exception only...
0
Yes I know control will come out of try block, but I don't mean to say that it solve the exception automatically, I want to ask whether only one except block can tell the error name by its own if we don't know what might be the possible error
Say in first line there is syntax error
then type error
then name error
can we use something like this
except Exception:
print (Exception)
and this always print the last line of the error you encounted each time
0
once again thanks