Question: Develop a function in python that plays a word guessing game. The minimum requirements for the game are as follows: Your program should randomly pick
Develop a function in python that plays a word guessing game. The minimum requirements for the game are as follows:
Your program should randomly pick a word from a list of words that you provide. You will use the choice method from the random library to accomplish this. An example of how you would do this is shown below:
import random # Imports the random module from the Python library into your function
mylist = ['word1', 'word2', ' word3', 'word4', 'word5'] # Your custom list of words
myword = random.choice(mylist) # Chooses a word from your list and saves it in a variable
Allow the user to input one letter for each guess.
For each correct guess, your function should store the chosen letters in their appropriate spot in a separate variable (make sure that if your word uses the same letters more than once that it fills in all of the slots where the letter belongs).
Display the current progress of filling in the letters after each guess whether it is right or wrong (for example, display 'c_ _ p _ _ _ r' if the user has guessed the letters c, p and r for the word "computer".
Display an appropriate message after each guess.
When a player has guessed incorrectly, display an appropriate 'incorrect' message and a count of how many letters are still missing from the word.
When a player guesses all of the letters in the word, display an appropriate congratulatory message and the number of attempts it took to guess it.
Allow for an unlimited number of guesses, but optionally you may add code to limit the number of guesses if you feel you can implement that capability and still ensure your code meets all of the other basic requirements.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
