Python: Guessing Hangman N Guillotine Game

The classic word game has player to guess the letters to a secret word. For each incorrect letter, the picture of hangman is slowly drawn. Try to guess the complete word before the hangman completes.

Making Hangman Game

hangman cartoon
hangman cartoon
  1. Define the game category as Animal and list of WORDS.
  2. Create the HANGMAN_PICS drawing.
hANGMAN CODE1
hANGMAN CODE1
HANGMAN CODE2
HANGMAN CODE2
  1. Define drawHangman function to check for missed Letters, correct Letters and secret Word.
  2. Display the CATEGORY
  3. If there is missing missed Letters, display missing letter.
  4. Next, display the correct Letters together with “_”.
  5. Define getPlayerGuess function is to ask for user to input for their guess.
    1. It check if the input guess is already guessed before
    2. It must be a single word.
HANGMAN CODE3
HANGMAN CODE3
  1. In the main function, we had the drawHangman function first.
  2. Ask for user to guess, check the guess word in secret Word.
  3. If it is part of secret Word, then correct Letters will be kept.
  4. For all the secret Word, is there found in all correct Letters.
    1. If Yes, then we print “You have won!”
    2. If No, missed Letters will be updated and check if the missed Letters is maximum to the HANGMAN_PICS, then show “You have run out of guess”
HANGMAN CODE4
HANGMAN CODE4

Finally, let have a guess game maybe you want to have a group of friends to play American game show Wheel of Fortune.

hangman demo
hangman demo

Thanks for reading and enjoy your day.

Leave a Reply

Your email address will not be published. Required fields are marked *




Enter Captcha Here :