Views
No views yet
# Initialize the number of attempts
attempts = 0
print("Welcome to the Guessing Game!")
print("I'm thinking of a number between 1 and 100. Can you guess what it is?")
# Start the game loop
while True:
# Get the player's guess
guess = input("Enter your guess (or 'q' to quit): ")
# Check if the player wants to quit
if guess.lower() == 'q':
print("Thanks for playing! The secret number was:", secret_number)
break
# Convert the guess to an integer
try:
guess = int(guess)
except ValueError:
print("Please enter a valid number or 'q' to quit.")
continue https://hdpcgames.com/genshin-impact-highly-compressed-download
# Increment the number of attempts
attempts += 1
# Check if the guess is correct
if guess == secret_number:
print("Congratulations! You guessed the secret number in", attempts, "attempts!")
break
elif guess < secret_number:
print("Too low! Try again.")
else:
print("Too high! Try again.")