From c61c2289e8a9b6dfa6bc2d5d1e8b6688fa9c1989 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Sun, 13 Nov 2016 11:00:07 +0100 Subject: [PATCH] add a menu point to exit the game --- tamagotchi.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tamagotchi.py b/tamagotchi.py index a1ebd9c..f644a42 100755 --- a/tamagotchi.py +++ b/tamagotchi.py @@ -5,6 +5,8 @@ import threading import pet_variables # a module which includes various custom functions import pet_functions +# import the sys function +import sys # Beginning of the main routine which makes up the actual game. @@ -32,7 +34,7 @@ while pet_functions.is_alive(): print("What would you like to do?") # Start the chosen activity and go back to the activity selector. print("1: Feeding, 2: Playing, 3: Stroke Pet,") - print("4: Poking, 5: Sleeping, 6: Show Stats") + print("4: Poking, 5: Sleeping, 6: Show Stats, 0: Exit") try: chosen_activity = int(input("Choose the desired activity:")) if chosen_activity == 1: @@ -47,6 +49,8 @@ while pet_functions.is_alive(): pet_functions.sleeping() elif chosen_activity == 6: pet_functions.pet_stats() + elif chosen_activity == 0: + sys.exit() except ValueError: pet_functions.pet_stats() print("Your pet died.")