This is a Python implementation of the classic Hangman game, where the player tries to guess a randomly selected phrase, one letter at a time. The goal is to guess the phrase before the gallows are fully drawn (6 incorrect guesses).
- Random phrase selection from an external file (
phrases.txt). - Interactive gameplay with input validation.
- Displays the hangman figure as incorrect guesses are made.
- Tracks guessed letters and reveals correctly guessed letters in the phrase.
- Supports case-insensitive guessing.
- When you start the game, you'll see a partially drawn gallows and the phrase represented as underscores (
_), hiding unguessed letters. - Guess one letter at a time by typing it in when prompted.
- Correct guesses reveal the letter in the phrase.
- Incorrect guesses add parts to the gallows.
- The game ends when:
- You guess the full phrase correctly, or
- You make 6 incorrect guesses, completing the gallows.
- Python 3.x
- Run the Game
- Open a terminal or command prompt.
- Navigate to the directory containing the script.
- Execute the script:
python hangman.py
*** Welcome to Hangman ***
+---+
| |
|
|
|
|
|_____
Incorrect guesses made: 0/6
____ __ _______
Letters guessed: []
Please enter a letter: A
...
- If
phrases.txtis missing, a default phrase will be used:
"When you gaze long into the abyss, the abyss gazes also into you" - If
phrases.txtis empty, the game will notify the user and terminate.
Feel free to submit issues or improvements to the code via pull requests.
This project is open-source and available under the MIT License.