Question
Helper 4: Getting the user's guess [7 marks] get_guessed_word(word_to_guess, letters_guessed): takes two parameters: a string, word_to_guess, and a list of letter, letters_guessed. This function returns
Helper 4: Getting the user's guess [7 marks]
get_guessed_word(word_to_guess, letters_guessed): takes two parameters: a string, word_to_guess, and a list of letter, letters_guessed. This function returns a string that is comprised of letters and underscores, spaces are optional, based on what letters in letters_guessed are in word_to_guess. This shouldn't be too different from isGoodGuess!
For readability separate each underscore with a space: _ _ _ _. Without a space it is hard to distinguish whether ____ is four elements or three ___. Adding the space helps to improve your program's usability.
def get_guessed_word(word_to_guess, letters_guessed): """ Provide function docstring """
return "YOUR ANSWER HERE"
Test get_guessed_word() to verify that the created string correctly presents the guessed letters in word_to_guess
def a4(): guess1 = get_guessed_word('apple', ['i']) guess2 = get_guessed_word('apple', ['l', 'i', 'k', 't', 'r', 's']) guess3 = get_guessed_word('apple', ['a', 'l', 'k', 'p', 'r', 'e']) if guess1 == '_ _ _ _ _' and guess2 == '_ _ _ l_' and guess3 == 'apple': return 'Correct' else: return 'Wrong' a4()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started