how to make python stop before closing a program and only after it can be close if we type close in input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how to make python stop before closing a program and only after it can be close if we type close in input

help am saying the output

4th May 2018, 5:27 PM
Anmol Dhakal
3 Answers
+ 1
So you’re saying stop the program when the user types in ‘close’? import sys usr_input = input() if usr_input == "close": sys.quit(0) Put it in a infinite loop or whatever
4th May 2018, 5:36 PM
TurtleShell
TurtleShell - avatar
0
I think you mean stop the program not Python you cannot close Python without the program closing too because it is an interpreter. Import the standard sys module then use sys.quit(0) which will stop the program.
4th May 2018, 5:32 PM
TurtleShell
TurtleShell - avatar
0
no the output i am saying
4th May 2018, 5:32 PM
Anmol Dhakal