Is there any option in python to exit the code, like the exit function in C/C ++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Is there any option in python to exit the code, like the exit function in C/C ++

29th Mar 2021, 3:19 AM
Sharad
3 Answers
+ 8
The exit() function of the sys module is what you're looking for. ``` import sys sys.exit(1) ``` The above lines exit the program with exit status 1
29th Mar 2021, 3:32 AM
XXX
XXX - avatar
+ 1
there is actually. in the python terminal, type exit() or hit ctrl-d.
29th Mar 2021, 3:27 AM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar
+ 1
yes, just: exit() or: ctrl + c
29th Mar 2021, 4:24 AM
Alfonso Farías
Alfonso Farías - avatar