Game
unknown
abc
a year ago
845 B
3
Indexable
Never
```python import random # Generate a random number between 1 and 100 secret_number = random.randint(1, 100) # Initialize the number of tries attempts = 0 print("Welcome to the Number Guessing Game!") print("I'm thinking of a number between 1 and 100.") while True: try: # Get the player's guess guess = int(input("Take a guess: ")) # Increase the number of attempts attempts += 1 # Check if the guess is correct if guess == secret_number: print(f"Congratulations! You guessed the number {secret_number} in {attempts} attempts.") break elif guess < secret_number: print("Try higher.") else: print("Try lower.") except ValueError: print("Please enter a valid number.") print("Thank you for playing!") ```