Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Quit function in python programming

I have tried to use the ‘quit()’ function in python and the spyder’s compiler keep says me "quit" is not defined

print("Welcome to my computer quiz")

playing = input("Do you want to play? ")

if (playing != "yes" ):
    quit()
    
print("Okay! Let's play :)")

the output keep says me "name ‘quit’ is not defined", how can i solve that problem?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Invert the logic and play if the user answers yes. The game will automatically quit when it reaches the end of the file

print("Welcome to my computer quiz")

playing = input("Do you want to play? ")

if (playing == "yes" ):
    print("Okay! Let's play :)")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading