Reference no: EM133914491
Problem
Write a Python program that plays an interactive "Guess the Word" game with the user. In this game, the user will try to guess a word by guessing one letter at a time. The program will display the word with some characters hidden as underscores (_). When the user guesses a correct letter, the corresponding underscores will be replaced by that letter. The game will continue until the user guesses all the letters correctly. You cannot use lists or arrays, but you can use the len() function. You should only use strings and simple loops. The program must be able to interact with the user by taking input and displaying results after each guess. For this task:
I. Initial Input: The program should first prompt the user to input a word to guess. This word should be kept hidden from the user and will only contain lowercase letters. Get the instant assignment help.
II. Word Display: Initially, display the word as a string of underscores (_), with each underscore representing a letter in the word. For example, if the word is "apple", display it as _ _ _ _ _.
III. Guessing: The program should repeatedly ask the user to guess one letter at a time. The user will input a letter, and the program should check if that letter exists in the word.
IV. Correct Guess: If the guessed letter is correct (i.e., it exists in the word), replace the corresponding underscores with the guessed letter. For example, if the word is "apple" and the user guesses "a", the display should change to a _ _ _ _.
V. Incorrect Guess: If the guessed letter is incorrect (i.e., it does not exist in the word), the program should notify the user that the guess is wrong and prompt them to try again.
VI. Game End: The game continues until all the letters in the word have been guessed correctly, replacing all underscores with the correct letters. When the word is completely guessed, the program should display a congratulatory message and end the game.