Professional Documents
Culture Documents
Hangman Game
Hangman Game
INTRODUCTION:
Welcome to Hangman, a classic word-guessing game where your goal
is to figure out the hidden word before it's too late! The rules are
simple:
Are you ready to test your vocabulary skills and save the hangman
from his fate? Let's play!
HOW TO PLAY HANGMAN GAME ?
To play Hangman, follow these steps:
1. Setup: One player (the "host") thinks of a word and writes down a
dash for each letter of that word, representing the unknown letters.
For example, if the word is "apple", they would write "_ _ _ _ _".
2. Guessing: The other player (the "guesser") starts guessing letters
that they think might be in the word. They can guess one letter at a
time.
3. Revealing Letters: If the guessed letter is in the word, the host
reveals all occurrences of that letter in the word. For example, if the
guess is "p" and the word is "apple", the host would reveal the two
"p"s: "_ p p _ _".
4. Incorrect Guesses: If the guessed letter is not in the word, the host
starts drawing parts of the hangman as a penalty. Commonly, there are
6 parts to draw: head, body, left arm, right arm, left leg, and right leg.
5. Continuation: The guesser continues guessing letters until they
either correctly guess the word (filling in all the blanks) or make too
many incorrect guesses, resulting in the completion of the hangman
figure.
6. Outcome: The game ends when the guesser either successfully
guesses the word or the hangman is fully drawn. If the guesser guesses
the word correctly, they win. If the hangman is completed before the
word is guessed, the host wins.
else:
display += "_"
return display
def hangman():
word = choose_word()
guessed_letters = []
attempts = 6
print("Welcome to Hangman!")
print("Try to guess the word.")
while attempts > 0:
print("\nAttempts left:", attempts)
print("Word:", display_word(word, guessed_letters))
if guess in guessed_letters:
print("You've already guessed that letter.")
continue
guessed_letters.append(guess)
else:
print("Thanks for playing!")
hangman()
Output: