Write a program that plays a game of Hangman. Hangman is a two-player game in which one player, in our case, the program, picks a word (you can hardcode it) that the other player (the user) has to guess. The program originally reveals only the first and the last letters, and dashes for every other letter, e.g. N------K, if the word is NOTEBOOK. At each turn of the game, the user suggests a letter and the program responds by either stating that the word does not have the letter, or revealing the letter in the word, e.g. o in NO---OOK.
The game stops when either
Here's a sample run of the program:
Let's play a game of Hangman.
I have picked a word that starts with letter T and ends with E.
Here's the template in which each dash denotes a single letter:
T - - - - - - - - - E
Now it's your turn to guess a letter.
Please enter your next guess: F
Incorrect. Letter F does not occur in this word.
Please enter your next guess: E
Correct.
T E - - E - - - - - E
Please enter your next guess: Z
Incorrect. Letter Z does not occur in this word.
Please enter your next guess: P
Correct.
T E - P E - - - - - E
Please enter your next guess: Q
Incorrect. Letter Q does not occur in this word.
Please enter your next guess: O
Incorrect. Letter O does not occur in this word.
Please enter your next guess: L
Incorrect. Letter L does not occur in this word.
Please enter your next guess: I
Incorrect. Letter I does not occur in this word.
You lost this game. The word is TEMPERATURE