How to end a program

Category: General

Last updated 6 days ago

Maya Parker

Maya Parker Asked 3 months ago

I was wondering what the command was for ending the program for example GAME OVER when the player makes the wrong decision and stopping all the code after that?


Jeff Plumb

Jeff Plumb Answered 6 days ago

You can call the quit() function and that will stop all code from running. You can also structure your code so that the condition in your game loop turns to False when you want the game to stop. For example:

playing = True
while playing:
    if <game over condition is True>:
        playing = False

That way the loop will keep going until the game over condition becomes True.


Notify me of updates
Add to Favourites
Back to Questions

No comments yet!


Become a free member to post a comment about this question.