try: print(1) print(10 / 0) except ZeroDivisionError: print(unknown_var) finally: print("This is executed last | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

try: print(1) print(10 / 0) except ZeroDivisionError: print(unknown_var) finally: print("This is executed last

Why is 1 printed?

1st Aug 2019, 4:42 AM
Dhyey Badheka
Dhyey Badheka - avatar
2 Answers
+ 3
Maybe you include code, can you post it here.
1st Aug 2019, 5:40 PM
Bapi
Bapi - avatar
+ 2
Because it is before the exception is encountered.
1st Aug 2019, 4:51 AM
Sonic
Sonic - avatar