Is the Word Guessed?
The program needs to know when to stop asking the user for letters if the word is guessed. To do that we implement the is_word_guessed function, which will say 'Ok, the user has guessed the gameword. We may stop the program and congratulate the player!'
Opgave
Swipe to start coding
- Set the
is_word_guessedfunction using thegamewordand theletters_already_guessedas arguments. - Set condition to check if the
letters_already_guessedis equal to thegameword. ! - Return
Trueif the condition is satisfied andFalseotherwise. - Test the function using the
test_gamewordandtest_letters_already_guessedlists. !Pay attention!while implementing2. ...task we need to useset(gameword) & set(letters_already_guessed)structure to equal it to thegameword. We do that because we need only letters fromletters_already_guessedthat are in thegameword.&- returns letters that are present in both words.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 3
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Awesome!
Completion rate improved to 7.69
Is the Word Guessed?
Stryg for at vise menuen
The program needs to know when to stop asking the user for letters if the word is guessed. To do that we implement the is_word_guessed function, which will say 'Ok, the user has guessed the gameword. We may stop the program and congratulate the player!'
Opgave
Swipe to start coding
- Set the
is_word_guessedfunction using thegamewordand theletters_already_guessedas arguments. - Set condition to check if the
letters_already_guessedis equal to thegameword. ! - Return
Trueif the condition is satisfied andFalseotherwise. - Test the function using the
test_gamewordandtest_letters_already_guessedlists. !Pay attention!while implementing2. ...task we need to useset(gameword) & set(letters_already_guessed)structure to equal it to thegameword. We do that because we need only letters fromletters_already_guessedthat are in thegameword.&- returns letters that are present in both words.
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 1. Kapitel 3
single