def choose_level(): while True: level = int(input("Enter your level by typing 1, 2 or 3\n")) if level in [1, 2, 3]: return level