Posted inPython

python terminate program – How to terminate a script?

python terminate program – Exit a Python Program in 3 Easy Ways Using quit() function, Python sys.exit() function and Using exit() function Example with demo.

python terminate program – How to stop/terminate a python script from running?

How to terminate a script? – To stop a running program, use Ctrl + C to terminate the process. A simple and effective method to exit a example in Python is to use the in-built quit() function.

Example 1: Using quit() function

for ucode in range(1,10):
    print(ucode*10)
    quit()

Example 2: Python sys.exit() function

import sys 
 
ucode = 50
 
if ucode != 100: 
    sys.exit("Sorry, Values do not match")  
else: 
    print("Validation of values done!!") 

Example 3: Using exit() function

for ucode in range(1,10):
    print(ucode*10)
    exit()

Don’t Miss : pause in python

I hope you get an idea about python terminate program.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype