import random

def guess(x):
    random_number = random.randint(1, x)
    guess = 0
    while guess != random_number:
        guess = int(input(f"Guess a number between 1 and {x}: "))
        if guess < random_number:
            print("Sorry, guess again. Too low.")
        elif guess > random_number:
            print('Sorry, guess again. Too high.')
    print(f'Yay! you guessed the number {random_number} correctly!')



def computer_guess(x):
    low = 1
    high = x
    feedback = ''
    while feedback != 'c': #can do this but would not let user tell them and low != high:
        #high and low cannot be same as they would represent the same number
        if low != high:
            guess = random.randint(low,high)
        else:
            #as high and low are the same could also be high as low = high
            guess = low
        feedback = input(f'Is {guess} too high (H), too low (L), or correct(C)?').lower()
        if feedback == 'h':
            high = guess - 1
        elif feedback == 'l':
            low = guess + 1
    print(f"The computer guessed your number, {guess}, correctly!")

#for user
guess(10)

#for computer
computer_guess(10)
