import random def guess_the_number(): number = random.randint(1, 100) tries = 0 while True: guess = int(input("Guess a number between 1 and 100: ")) tries += 1 if guess < number: print("Too low!") elif guess > number: print("Too high!") else: print(f"Congratulations! You guessed the number in {tries} tries.") break # To play the game # guess_the_number()