Untitled
unknown
plain_text
4 months ago
670 B
8
Indexable
import random
print("🎮 Welcome to Guess The Number!")
print("I'm thinking of a number between 1 and 100.")
# Generate random number
secret_number = random.randint(1, 100)
attempts = 0
while True:
guess = input("Enter your guess: ")
# Make sure input is a number
if not guess.isdigit():
print("Please enter a valid number!")
continue
guess = int(guess)
attempts += 1
if guess < secret_number:
print("Too low! Try again.")
elif guess > secret_number:
print("Too high! Try again.")
else:
print(f"🎉 Correct! You guessed it in {attempts} attempts!")
breakEditor is loading...
Leave a Comment