Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
688 B
5
Indexable
Never
import random

def generate_random_number():
    random_number = random.randint(1, 100)
    return random_number

random_number = generate_random_number()
print(f"Random number generated: {random_number}")

def guess_number_game():
    user_guess = int(input("Try to guess random number: "))
    return user_guess


a = 1

while a <= 10:
    user_guess = guess_number_game()

    if user_guess > random_number:
        print(f"Your guess is too high!")
        a = a + 1
    elif user_guess < random_number:
        print(f"Your guess is too low!")
        a = a + 1
    elif user_guess == random_number:
        print(f"Your guess is correct!")
        break
Leave a Comment