How to stop the Code After exception (Solved) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to stop the Code After exception (Solved)

Is it possible to stop the Code before the last Print if the exception occurs? (If the input os Not a number) https://code.sololearn.com/cBzhNh4AjIhg/?ref=app

20th Jun 2021, 1:57 PM
Angela
Angela - avatar
3 Answers
+ 3
import sys ... sys.exit()
20th Jun 2021, 2:02 PM
Slick
Slick - avatar
+ 2
The functions quit(), exit(), sys.exit() and os._exit() have almost same functionality as they raise the SystemExit exception by which the Python interpreter exits and no stack traceback is printed. https://www.google.com/amp/s/www.geeksforgeeks.org/python-exit-commands-quit-exit-sys-exit-and-os-_exit/amp/
20th Jun 2021, 5:17 PM
David Ashton
David Ashton - avatar
+ 1
Thanks
20th Jun 2021, 2:26 PM
Angela
Angela - avatar