0

Dont clearly understand whats happening. Pls help!

I tried getting both exceptions to come up but the program kept choosing the last exception alone as output despite there being errors to bring up both exception. Pls whats going on. try: Variable=10 M=0 print(variable +'' ") print(variable/M) except ZeroDivisionError: print("divided by zero") except(TypeError, ValueError): print('Error occured')

2nd Apr 2020, 5:48 PM
Abduljalal
Abduljalal - avatar
3 ответов
+ 2
Python is interpreted line by line therefore exception 1st will only detect 1st print function and it won't detect the 2nd unless the 1st print function gets stable and so exception 1 gets false and skipped.
2nd Apr 2020, 5:57 PM
Tricker
0
So ur saying that multiple exceptions cant come up at a time in python, as 1 appears it must me attended to b4 the next exception can come up.
2nd Apr 2020, 6:17 PM
Abduljalal
Abduljalal - avatar
0
Yes.
3rd Apr 2020, 5:25 AM
Tricker