Unit 5: Programming in Python Name: _________________
String Manipulation Programming Assignment
Hangman
You will be creating a program that plays the classic game
of Hangman.
Before you game begins, you will have the computer
randomly choose a word for the player to guess. The game
will then display the mystery word as a series of asterisks
("*") and the player has a certain number of guesses to guess
the letter. The player wins if they guess the word before they
run out of guesses.
Example Word: COMPUTER
revealWord ******** ******** C******* C******R C******R C*M****R C*M****R
guessesLeft 5 4 4 4 3 3 3
guessedLetters A AC ACR ACRI ACRI ACRI
playerGuess A C R I M A …
Although your output can vary, here are the basics you should have (although you can spruce things up however
you like)
Welcome to Hangman! You have to guess the mystery word in 5 guesses or
less.
Here's what you have so far: ********
You have 5 guesses left
Here are the letters you have guessed so far:
What letter would you like to guess next? A
I'm sorry…
Here's what you have so far: ********
You have 4 guesses left
Here are the letters you have guessed so far: A
What letter would you like to guess next? C
CORRECT!!!
Here's what you have so far: C*******
You have 4 guesses left
Here are the letters you have guessed so far: A C
What letter would you like to guess next? R
CORRECT!!!
Here's what you have so far: C******R
You have 4 guesses left
Here are the letters you have guessed so far: A C R
What letter would you like to guess next?
…
(at the end, either congratulate or console the user)
The game should end either after the user has guessed the entire word or they have run out guesses. In either
case, they should be told the result of the game (win or loss). In the even that they lose, the mystery word
should be displayed.
Extra Credit Options:
• Can you output a hangman? For each guess, a piece is added to the "hangman" and once the user runs
out of guesses, the hangman is complete.
• Put the guessed letters in alphabetical order
• Make it so the user can input lower case or upper case letters