Untitled
unknown
plain_text
7 months ago
652 B
1
Indexable
Never
def number_guess_game(): print("Welcome to the Number Guessing Game!") print("I'm thinking of a number between 1 and 100. Can you guess it?") secret_number = random.randint(1, 100) attempts = 0 while True: guess = int(input("Enter your guess: ")) attempts += 1 if guess < secret_number: print("Too low! Try again.") elif guess > secret_number: print("Too high! Try again.") else: print(f"Congratulations! You guessed the number {secret_number} correctly in {attempts} attempts!") break number_guess_game()
Leave a Comment