Contenu du cours
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.
Tâche
Swipe to start coding
- Define the
get_available_lettersfunction withletters_already_guessedas a parameter. - Initialize the
available_listvariable withstring.ascii_lowercaseto obtain the alphabet. - Create a
forloop to iterate through theavailable_listin reverse order. - Implement a condition to check if a letter in the
available_listmatches any inletters_already_guessed. - Remove the letter from the
available_listif it has already been guessed.
Solution
Mark tasks as Completed
Tout était clair ?
Merci pour vos commentaires !
Section 1. Chapitre 5
AVAILABLE TO ULTIMATE ONLY