# Untitled

unknown

plain_text

a year ago

850 B

1

Indexable

Never

^{}

import random # Generate a random number between 1 and 100 secret_number = random.randint(1, 100) # Initialize variables attempts = 0 max_attempts = 10 # Game loop while attempts < max_attempts: # Get the player's guess guess = int(input("Guess the secret number (between 1 and 100): ")) # Increment the attempts attempts += 1 # Check if the guess is correct if guess == secret_number: print(f"Congratulations! You guessed the secret number {secret_number} in {attempts} attempts.") break elif guess < secret_number: print("Try a higher number.") else: print("Try a lower number.") # If the player couldn't guess the number in max_attempts if attempts == max_attempts: print(f"Sorry, you've reached the maximum number of attempts. The secret number was {secret_number}.")