Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


How to readjust arguments based on input?

This is from the Number Game app except the reverse version where I have the computer guess my number. I've looked through the old posts for this app and have realized the need to adjust my arguments (lower, upper) after the initial guess, but I'm not sure how to go about it. This is what I have so far.

import random
wrong_guess = []
guess = random.randint(1, 10)
def game():
    while len(wrong_guess) < 5:
        lower = ()
        upper = ()
        guess = random.randint(lower, upper)
        answer = input("Is your number " + str(guess) + "? Enter Y/N: ")
        if answer.upper() == 'Y':
            print("Ah ha! {} was your number. That was fun!".format(guess))
            play_again = input("Wanna play again? Enter Y/N: ")
            if play_again.upper() == 'Y':
                print("OK! Let's play again next time!")
            hl_ans = input("Was my guess too high or too low? Enter H/L: ")
            if hl_ans.upper() == 'H':
                upper = guess
            elif hl_ans.upper() == 'L':
                lower = guess