16-is-dead/clean_input.py

34 lines
881 B
Python

"""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:
while True:
try:
i = str(input(message))
except (ValueError, NameError):
print("Eingabe nicht gültig, bitte wiederhole deine Eingabe.")
if i in options:
return i
break
else:
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()