Untitled
unknown
plain_text
2 years ago
652 B
8
Indexable
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()Editor is loading...
Leave a Comment