import random
# Setup game variables
min_number = 1
max_number = 20
secret_number = random.randint(min_number, max_number)
guesses_taken = 0
print("Welcome to 'Guess the Number' game!")
print(f"I'm thinking of a number between {min_number} and {max_number}.")
# Game loop
while True:
# Player input
guess = int(input("Take a guess: "))
guesses_taken += 1
# Guess evaluation
if guess < secret_number:
print("Too low!")
elif guess > secret_number:
print("Too high!")
else:
# Correct guess
print(f"Great job! You guessed the number in {guesses_taken} attempts.")
break
print("Thanks for playing!")