16-is-dead/clean_input.py

20 lines
527 B
Python
Raw Normal View History

2020-12-09 11:24:01 +01:00
"""clean_input"""
#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:
print('Noch nicht ganz richtig. Hast du deine Auswahl auch richtig geschrieben?')