TDT4109/Exercise 1/common.py

7 lines
182 B
Python

def inputTypeCheck(message, type, errorMessage):
while True:
inputValue = input(message)
try:
return type(inputValue)
except ValueError:
print(errorMessage)