import random
MAX_GUESSES = 40

lowlim = input('What do you want the lower limit to be for the guessing range?')
lowlim = int(lowlim)  # coverts the string the user entered into an int

uplim = input('What do you want the upper limit to be for the guessing range?')
uplim = int(uplim)  # coverts the string the user entered into an int

mysterynum = random.randint(lowlim, uplim) # will generate an integer from lowlim to uplim (inclusive)

guess = input('Enter a guess between ' + str(lowlim) + ' and ' + str(uplim) + ': ')
guess = int(guess)

guesscount = 1
#if guess == mysterynum:
#    print('Congratulations!')

while guess != mysterynum:
    if guesscount >= MAX_GUESSES:
        print('Sorry you exceeded the number of guesses.')
        print('The answer was', mysternum)
        break
    print('Sorry that was incorrect')
    if guess < mysterynum:
        print('Your guess was too low')
    else:
        print('Your guess was too high')
    guess = input('Enter a guess between ' + str(lowlim) + ' and ' + str(uplim) + ': ')
    guess = int(guess)
    guesscount += 1

if guesscount < MAX_GUESSES:
    print('Congratulations, you got it!!!!')

