Course Content
Crafting a Classic Hangman Game
Crafting a Classic Hangman Game
State of Affairs
Tracking the Game Word's Progress
To keep the user informed about the progress of their guesses, it's essential to display both the number of correctly guessed letters and the letters still to be guessed after each attempt.
For this purpose, we will develop the get_guessed_word
function. This function will maintain a result_list
, which represents the current state of the gameword
, including correctly guessed letters and placeholders for the remaining letters.
Task
- Define the
get_guessed_word
function withgameword
andletters_already_guessed
as parameters. - Create a for loop to iterate through
gameword
usingi
as the iterator, utilizing therange()
function for iteration. - Implement a condition to determine if elements within
gameword
match any inletters_already_guessed
. - If the condition is met, append the letter
list(gameword)[i]
toresult_list
; otherwise, append'_ '
(including the space).
Thanks for your feedback!
Tracking the Game Word's Progress
To keep the user informed about the progress of their guesses, it's essential to display both the number of correctly guessed letters and the letters still to be guessed after each attempt.
For this purpose, we will develop the get_guessed_word
function. This function will maintain a result_list
, which represents the current state of the gameword
, including correctly guessed letters and placeholders for the remaining letters.
Task
- Define the
get_guessed_word
function withgameword
andletters_already_guessed
as parameters. - Create a for loop to iterate through
gameword
usingi
as the iterator, utilizing therange()
function for iteration. - Implement a condition to determine if elements within
gameword
match any inletters_already_guessed
. - If the condition is met, append the letter
list(gameword)[i]
toresult_list
; otherwise, append'_ '
(including the space).