Python Python Basics (2015) Letter Game App Letter Game Refinement

Ezekiel Wootton
Ezekiel Wootton
1,219 Points

else: 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
Rob Enderle
2,164 Points

The 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)