From 4ae599735fc5c76ec89a9e441f9a3deae84269e6 Mon Sep 17 00:00:00 2001 From: adamercat Date: Thu, 10 Dec 2020 10:13:16 +0100 Subject: [PATCH] new Quit and Restart functionality --- clean_input.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/clean_input.py b/clean_input.py index 5fb84bf..1b2f4f2 100644 --- a/clean_input.py +++ b/clean_input.py @@ -1,5 +1,7 @@ """clean_input""" +import sys +import #main_gamemodule_plz_here #message needs to be a string that is printed for user instruction. options is a list of viable inputs def io(message: str, options: list) -> str: @@ -13,7 +15,19 @@ def io(message: str, options: list) -> str: if i in options: return i break + else: - print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?') + try: + print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?') + + except(i =='QUIT' or i == 'RESTART'): + + if i == 'QUIT': + print("Spiel wird beendet...") + sys.exit() + + if i == 'RESTART': + print("Spiel wird neu gestartet...") + #main_gamemodule_plz_here.game()