def int_check(low, high): """Checks user enters an integer less, or more than or equal to the low and high numbers.""" error = f"Please enter an integer more than or equal to {low} or less than or equal to. {high}" while True: try: response = int(input("Enter a number to select a level: ")) if response >= low and response <= high: return response else: print(error) except ValueError: print(error) # Main routine starts here game_goal = int_check(1, 5) second_goal = int_check(7, 11) print(f"You chose level: {game_goal} and the second level of {second_goal}")