Kursinnehåll
Crafting a Classic Hangman Game
Crafting a Classic Hangman Game
 Guessed Word
Guessed Word
Preventing Excessive Gameplay
The program must recognize when to cease prompting the user for letters once the word has been successfully guessed. To achieve this, we'll develop the is_word_guessed function. This function will effectively communicate:
Great, the player has guessed the word correctly! It's time to halt the program and congratulate the player.
Uppgift
Swipe to start coding
- Define the is_word_guessedfunction withgamewordandletters_already_guessedas parameters.
- Implement a condition to verify whether letters_already_guessedmatchesgameword.
- Return Trueif the condition is met, andFalseotherwise.
Lösning
Note
During the execution of the second step, employ the
set(gameword) & set(letters_already_guessed)expression to compare it with theset(gameword). This approach ensures that only the letters fromletters_already_guessedthat are ingamewordare considered. The&operator identifies letters common to both sets.
Mark tasks as Completed
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 3
AVAILABLE TO ULTIMATE ONLY