Untitled
unknown
plain_text
a year ago
776 B
0
Indexable
Never
import random def number_guessing_game(): secret_number = random.randint(1, 100) attempts = 10 print("Welcome to the Number Guessing Game!") print("I'm thinking of a number between 1 and 100.") while attempts > 0: print(f"You have {attempts} attempts left.") guess = int(input("Enter your guess: ")) if guess < secret_number: print("Higher!") elif guess > secret_number: print("Lower!") else: print(f"Congratulations! You guessed the correct number {secret_number}!") break attempts -= 1 if attempts == 0: print(f"Sorry, you've run out of attempts. The correct number was {secret_number}.") number_guessing_game()