Python 3.6
Requriements:
Submit only the files requested
Print all floats to 2 decimal points unless stated otherwise
Restrictions:
No global variables may be used
NEW: The only code that may appear outside of a function are function definitions and function calls
NEW: You may not import any modules
Description:
You will be implementing the game hangman. In hangman one player chooses a secret word and the other player guesses letters. Each time the second player guesses a correct letter, all instances of that letter in the secret word are revealed. If the second player guesses a letter that is not in the word, then a portion of the hangman is drawn. The game ends once the entire hangman is drawn or the second player guesses all of the letters that are in the word. You can play hangman here.
Details:
The second player has 7 guesses to guess the correct word
After each incorrect guess the pieces of the hangman are drawn in the following order: rope, head, torso, left arm, right arm, left leg, and right leg
At the beginning of the game the first player should be asked to enter the secret word.
The letters in the secret word should be displayed as ? until the user guesses them
After the secret word is entered 30 new lines should be printed to the screen to hide the secret word
Don't forget you can multiply a string by a number here to save yourself some typing
At the beginning of each round you should display the following in this order
The hanged man
The partially guessed secret word
The characters guessed so far in sorted order
If the user guesses a letter they have already guessed they should be told they already guessed that letter and be asked to enter a new guess
These guesses should not be counted against the user
Assumptions:
Input will not always be valid
If invalid input is received your program should continue to ask for more input until a valid value is entered
Valid Values for Input:
Secret Word: Any string that does not contain ? or whitespace characters
Guess: a single letter that has not already been guessed
Strip whitespace from the guess before checking it
If only whitespace is entered it is treated like the user didn't enter anything
Hints:
Use functions to help you solve this problem. Breaking it down into steps and and turning each step into a function will make solving this problem a lot easier. Some functions I hade were
get_secret_word
get_guess
is_game_over
display_hangman
display_guesses
Examples
For space reasons the 30 new lines aren't shown.