Get GameWord
After every guess, we need to allow the user to understand the state of his/her guesses. We need to allow to see the number of right letters guessed already and the remaining letters that are needed to be guessed. To do that we create the get_guessed_word function.
Scroll down to see the whole task code!
Swipe to start coding
result_list is a list with the curent state of the gameword: right letters and gaps.
- Set the
get_guessed_wordfunction using thegamewordand theletters_already_guessedas arguments. - Set the
forloop to work with thegamewordusingias an iterator andrange()function. - Set condition to check if elements of the
gamewordare equal to theletters_already_guessed. - Append the letter
list(gameword)[i])to the theresult_listif condition is satisfied, append'_ '(with the space) otherwise. - Test the function using the
test_gamewordandtest_letters_already_guessedlists.
Løsning
Tak for dine kommentarer!
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
Opsummér dette kapitel
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 7.69
Get GameWord
Stryg for at vise menuen
After every guess, we need to allow the user to understand the state of his/her guesses. We need to allow to see the number of right letters guessed already and the remaining letters that are needed to be guessed. To do that we create the get_guessed_word function.
Scroll down to see the whole task code!
Swipe to start coding
result_list is a list with the curent state of the gameword: right letters and gaps.
- Set the
get_guessed_wordfunction using thegamewordand theletters_already_guessedas arguments. - Set the
forloop to work with thegamewordusingias an iterator andrange()function. - Set condition to check if elements of the
gamewordare equal to theletters_already_guessed. - Append the letter
list(gameword)[i])to the theresult_listif condition is satisfied, append'_ '(with the space) otherwise. - Test the function using the
test_gamewordandtest_letters_already_guessedlists.
Løsning
Tak for dine kommentarer!
single