I have a long code that sometimes I do not want to execute all of the code, but just stop at a certain line. To stop the execution of a code at a line, I do the following:
print('Stop here: Print this line')
quit()
print('This line should not print because the code should have stopped')
The right answer is only the first line should print. When I use quit()
, quit
, exit()
, or exit
both lines print. When I use import sys
and then sys.exit()
I get the following error message
An exception has occurred, use %tb to see the full traceback. SystemExit C:\Users\user\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3351: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D. warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
How can I perform this task of stopping execution at a line?