Code to close a python program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Code to close a python program?

I'm beginner to python. I've learnt java there's one line to close/exit the program ('System.exit (0)'). I'm curious if there's any in python.

8th Mar 2020, 4:12 PM
Amit Verma
Amit Verma - avatar
3 Answers
+ 7
There's a module sys that allows the same technique: from sys import exit exit(0)
8th Mar 2020, 4:15 PM
HonFu
HonFu - avatar
+ 3
exit() does the trick (tested in SL and Pythonista).
8th Mar 2020, 5:29 PM
Russ
Russ - avatar
+ 2
It depends on the specific runtime if exit is available just like that. There's also 'quit'.
8th Mar 2020, 6:15 PM
HonFu
HonFu - avatar