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

Ashley Keeling
Ashley Keeling
11,476 Points

what is 'done'?

in the video he uses done as a argument for the play function , I don't get where it has come from. thanks

1 Answer

Chris Freeman
Chris Freeman
Treehouse Moderator 59,587 Points

done is used as a parameter for the play function to determine if play should begin. Initially, done should be False otherwise you would only get one guess before the if done: statement is reached and the code asks to play again.

The initial value of done needs to be passed into the play function using:


# or 


Hi Chris,

So done = True means you lost in this exercise and done =False would be vice versa?

Is this because he set done = False at the bottom? if done = True, what happens? Definitely hard to follow, For a while, I've been trying to get a good understanding of what Kenneth Love was trying to write for this 1 video alone -.-

Chris Freeman
Chris Freeman
Treehouse Moderator 59,587 Points

When I am trying to understand what a variable is used for, I break the process into two parts.

Under what conditions is the variable set

At the bottom of the code, the variable done is set to False as the game starts. In the game, done is set to True when the play ends due the all secret letters guessed or too many bad guesses made.

How is the variable used in other statements

The variable done is used to control whether or not to ask if the game should continue. If done is True, ask the questions, otherwise skip it and continue the game.

So now knowing why the variable done gets set and what it controls its purpose might be clearer.

This is also an example of how a variable name might make the code more understandable. Perhaps the code would be clearer if, instead of done, the variable was named "ask_to_start_new_game".