import random def main(): n = -1 while n < 1: try: n = int(input("Level: ")) except (TypeError, ValueError): continue random.seed() n_to_guess = random.randint(1, n) guess = -1 while n_to_guess - guess != 0: try: guess = int(input("Guess: ")) except (TypeError, ValueError): continue if guess == n_to_guess: print("Just right!") if guess < n_to_guess: print("Too small!") if guess > n_to_guess: print("Too large!") if __name__ == "__main__": main()