0
Why this code didn't run try and finally statement
5 Respuestas
+ 1
Ansab Khan
print(""unknown_var"")
Giving syntax error that's why finally statement not running.
And
print(unknown_var)
Giving error that's why it running finally statement.
I think now you got your answer.
try to run on computer then you can understand more better.
+ 2
Right:
print("unknown_var")
Wrong:
print(""unknown_var"")
0
try:
print(1)
print(10 / 0)
except ZeroDivisionError:
print(unknown_var)
finally:
print("This is executed last")
Guys this is also shows error in line 5 but the main point is this code prints finally statement but with two strings it didn't why??
0
thanks