Write a python program that will let the user play Hangman as shown in the examp
ID: 3677716 • Letter: W
Question
Write a python program that will let the user play Hangman as shown in the examples below. The user will guess letters until either: They have correctly guessed all the letters in the word or they have incorrectly guessed 6 times. At each turn, display the player’s progress by showing the word they’re guessing in all capital letters, with all non-guessed characters replaced by dashes (“-”). Suggested Approach Here’s one possible way to approach this program: Prompt the user to enter a word Create a display string with the right number of hyphens (loop and add one for each letter in the target word). For each letter they guess, If the letter is not in the target word, count a miss Otherwise, make a new display string by loop through the target word’s letters if the letter matches their guess, add it to the new display string if the letter does not match their guess, copy whatever was in that spot of the old display string over replace the old display string with the new one If they have too many misses, tell them they lose; if there are no - left in the display string, tell them they win.
The specific output example format is shown in the examples below:
Enter a word: HANGMAN
[-------] You have 6 left, enter a letter: A
Correct!
[-A---A-] You have 6 left, enter a letter: B
Incorrect! [-A---A-] You have 5 left, enter a letter: C
Incorrect! [-A---A-] You have 4 left, enter a letter: D
Incorrect! [-A---A-] You have 3 left, enter a letter: E
Incorrect! [-A---A-] You have 2 left, enter a letter: F
Incorrect! [-A---A-] You have 1 left, enter a letter: G
Correct! [-A-G-A-] You have 1 left, enter a letter: K
You lose! The word was “HANGMAN”
ANOTHER EXAMPLE
Enter a word: COMPUTER
[--------] You have 6 left, enter a letter: E
Correct! [------E-] You have 6 left, enter a letter: B
Incorrect! [------E-] You have 5 left, enter a letter: C
Correct! [C-----E-] You have 5 left, enter a letter: A
Incorrect! [C-----E-] You have 4 left, enter a letter: P
Correct! [C--P--E-] You have 4 left, enter a letter: E
Correct! [C--P--E-] You have 4 left, enter a letter: R
Correct! [C--P--ER] You have 4 left, enter a letter: M
Correct! [C-MP--ER] You have 4 left, enter a letter: A
Incorrect! [C-MP--ER] You have 3 left, enter a letter: T
Correct! [C-MP-TER] You have 3 left, enter a letter: O
Correct! [COMP-TER] You have 3 left, enter a letter: U
You win! The word was “COMPUTER”
another example
Enter a word: Aa
[--] You have 6 left, enter a letter: a
You win! The word was “AA”