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_word
function using thegameword
and theletters_already_guessed
as arguments. - Set the
for
loop to work with thegameword
usingi
as an iterator andrange()
function. - Set condition to check if elements of the
gameword
are equal to theletters_already_guessed
. - Append the letter
list(gameword)[i])
to the theresult_list
if condition is satisfied, append'_ '
(with the space) otherwise. - Test the function using the
test_gameword
andtest_letters_already_guessed
lists.
Lösning
Tack för dina kommentarer!
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Awesome!
Completion rate improved to 7.69
Get GameWord
Svep för att visa menyn
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_word
function using thegameword
and theletters_already_guessed
as arguments. - Set the
for
loop to work with thegameword
usingi
as an iterator andrange()
function. - Set condition to check if elements of the
gameword
are equal to theletters_already_guessed
. - Append the letter
list(gameword)[i])
to the theresult_list
if condition is satisfied, append'_ '
(with the space) otherwise. - Test the function using the
test_gameword
andtest_letters_already_guessed
lists.
Lösning
Tack för dina kommentarer!
Awesome!
Completion rate improved to 7.69single