Course Content
Crafting a Classic Hangman Game
Crafting a Classic Hangman Game
Available Letters
Displaying Available Letters
To assist users, we display the letters that are still available for guessing after each attempt. Any letter that has been guessed should be removed from the available_list
. For this purpose, we will implement the get_available_letters
function.
Task
- Define the
get_available_letters
function withletters_already_guessed
as a parameter. - Initialize the
available_list
variable withstring.ascii_lowercase
to obtain the alphabet. - Create a
for
loop to iterate through theavailable_list
in reverse order. - Implement a condition to check if a letter in the
available_list
matches any inletters_already_guessed
. - Remove the letter from the
available_list
if it has already been guessed.
Thanks for your feedback!
Displaying Available Letters
To assist users, we display the letters that are still available for guessing after each attempt. Any letter that has been guessed should be removed from the available_list
. For this purpose, we will implement the get_available_letters
function.
Task
- Define the
get_available_letters
function withletters_already_guessed
as a parameter. - Initialize the
available_list
variable withstring.ascii_lowercase
to obtain the alphabet. - Create a
for
loop to iterate through theavailable_list
in reverse order. - Implement a condition to check if a letter in the
available_list
matches any inletters_already_guessed
. - Remove the letter from the
available_list
if it has already been guessed.