Untitled

 avatar
unknown
plain_text
10 months ago
780 B
11
Indexable
import random

print("Welcome to the Guess the Number Game!")
print("I am thinking of a number between 1 and 100.")

# Generate a random number between 1 and 100
number_to_guess = random.randint(1, 100)
attempts = 0
user_guess = 0

while user_guess != number_to_guess:
    user_guess = int(input("Enter your guess: "))
        attempts += 1

            if user_guess < number_to_guess:
                    print("Too low! Try again.")
                        elif user_guess > number_to_guess:
                                print("Too high! Try again.")
                                    else:
                                            print(f"Congratulations! You guessed the number {number_to_guess} in {attempts} attempts!")
                                            k
Editor is loading...
Leave a Comment