def check_input(predicate, msg, error_string='Illegal Input'):
    while True:
        result = input(msg).strip()
if predicate(result):
    return result
print(error_string)
python library for user input