import random
# generate a random number between 1 and 100
secret_number = random.randint(1, 100)
# initialize the number of tries
num_of_tries = 0
# greet the player
print("Welcome to the number guessing game!")
print("I'm thinking of a number between 1 and 100.")
# loop until the player guesses the correct number or runs out of tries
while num_of_tries < 10:
# prompt the player to guess the number
guess = int(input("Take a guess: "))
# increment the number of tries
num_of_tries += 1
# check if the guess is correct
if guess == secret_number:
print("Congratulations! You guessed the number in", num_of_tries, "tries.")
break
elif guess < secret_number:
print("Your guess is too low.")
else:
print("Your guess is too high.")
# if the player runs out of tries without guessing the correct number, show the secret number
if num_of_tries == 10:
print("Sorry, you didn't guess the number in time. The secret number was", secret_number, ".")