Conteúdo do Curso
Crafting a Classic Hangman Game
Crafting a Classic Hangman Game
Guessed Word
![](https://codefinity-content-media.s3.eu-west-1.amazonaws.com/7858f70a-18ff-4415-855e-b78c0489d4ed/is+word+guessed.png)
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.
Tarefa
- Define the
is_word_guessed
function withgameword
andletters_already_guessed
as parameters. - Implement a condition to verify whether
letters_already_guessed
matchesgameword
. - Return
True
if the condition is met, andFalse
otherwise.
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_guessed
that are ingameword
are considered. The&
operator identifies letters common to both sets.
Tudo estava claro?