How can you tell Python 🐍 not to run the final statement if the try statement is true or also ran? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

How can you tell Python 🐍 not to run the final statement if the try statement is true or also ran?

Final statements.

7th Oct 2019, 4:26 PM
Divine Darkey
Divine Darkey - avatar
2 Answers
+ 4
Yh, something like that.
7th Oct 2019, 5:44 PM
Divine Darkey
Divine Darkey - avatar
+ 3
You mean `finally` statement? The lesson says the `finally` block (when present) will be executed whether or not an exception be raised. I guess you can just remove the `finally` block, and use only the `try` and `except`block pair, if you don't want the `finally` block at all. https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2442/
7th Oct 2019, 4:39 PM
Ipang