guess the number

mail@pastecode.io avatar
unknown
java
11 days ago
584 B
3
Indexable
Never
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!")
Leave a Comment