Let’s see how to stop python program.
Ways to stop Python
To implement the way to stop Python program you need to import os python module. In os module there is a way to kill the python process. It is sys.exit(0).
You can implement something like this:
from os import sys def my_function(): #aaa #bbb #ccc stop_program = input('Press c to stop the program') if stop_program == 'c': sys.exit(0) else: my_function() my_function()
Python code will be stopped after pressing c letter. C is the most intuitive button. Linux users are accustomed to use CTRL + C.