# # Play a simple number guessing game with the user. # import random # Pick a random target value between 1 and 100 target = random.randrange(1, 101) # Read the first guess from the user and count it guess = int(input("Enter your guess: ")) count = 1 # While the guess is not equal to the target while guess != target: # Report if the guess is too high or too low if guess < target: print("Too low!") else: print("Too high!") # Read the next guess from the user and count it guess = int(input("Enter your guess: ")) count = count + 1 # Report the number of guesses and that the target was found print("You found it! And it only took", count, "guesses.")