guess the number

 avatar
unknown
java
a year ago
584 B
6
Indexable
import random

# Generate a random number between 1 and 100
number = random.randint(1, 100)

print("Welcome to Guess the Number Game!")

while True:
    # Ask the player for a guess
    guess = int(input("Enter your guess: "))

    # Compare the player's guess with the random number
    if guess < number:
        print("Too low!")
    elif guess > number:
        print("Too high!")
    else:
        # Congratulations! The player guessed correctly.
        print("Congratulations! You guessed the correct number!")
        break

print("Thanks for playing!")
Editor is loading...
Leave a Comment