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! While you're at it, check out some resources Treehouse students have shared here.
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 trialGeorge Lewiss
1,219 Pointselse: return guess
Why do we add else: return guess in the get_guess function? Is that what is causing the good_guesses to be drawn on screen? If not, what is causing the good_guesses to be drawn on screen because we aren't using the draw function inside the game function to draw good_guesses. We only use that function for the bad_guesses. Sorry. I'm really confused.
1 Answer
Rob Enderle
2,164 PointsThe get_guess function takes two arguments, bad_guesses and good_guesses. The function asks for input and checks whether the user entered more than one letter, entered a number they have already guessed or they entered a non-alpha character.
If the user entered a valid, non-guessed letter, that letter is returned by the function. When something is returned by a function, you'll most likely want to do something with it. In the play function, the value of guess is assigned to whatever is returned by the get_guess function with the line guess = get_guess(good_guesses, bad_guesses).
The drawing of the guesses on screen takes place in the draw function, which is being called from within the play function, which is called from the last while loop
while True:
clear()
welcome()
play(done)
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 Pointschanged comment to answer