A fun and interactive command-line Hangman game written in Python.
This project includes a modular structure, ASCII-art hangman graphics, score saving, input validation, and a clean UI flow.
- 🎯 Random word selection from a built-in word bank
- 💀 ASCII hangman graphics updated with each wrong guess
- 🧠 Smart input validation (only single alphabetic letters)
- 💾 Save game results to
save.csv - 🧩 Modular code structure (
logicmodule + main script) - 🔄 Clean menu (Start Game / Save Results / Exit)
- 🧼 Works on Windows & Linux (auto screen clear)
Hangman Game/
│
├── logic/
│ ├── __init__.py # Makes 'logic' a package
│ └── logic.py # Game logic + ASCII art + CSV saving
│
├── hangman.py # Main game script (was main.py)
├── .gitignore # Git ignore file
└── README.md # Project documentation
Quick demo of the Hangman gameplay — guessing letters, ASCII updates, and win/lose logic.
git clone https://github.com/AliBahrami-ce/Hangman-game.git
cd Hangman-gamepython main.pyYou will see:
- Intro message
- First hangman ASCII frame
- A hidden word displayed as
_ _ _ _
- Enter one letter at a time
- Correct guess → updates the hidden word
- Wrong guess → updates Hangman
- You have 6 attempts
If attempts reach 6 → the stickman dies (L)
If you guess all letters → you win (W)
Choosing option 2 – Save Results writes a CSV file:
save.csv
| # | Word | W/L |
|---|---|---|
| 1 | python | W |
| 2 | robot | L |
Handles:
- Menu
- UI
- Word selection
- Input validation
- Game loop
Contains:
- ASCII hangman frames
logicclass- Correct/wrong guess handling
- Saving results to CSV
- Python 3.8+
- No external dependencies
- Difficulty levels
- GUI version (Tkinter / PyGame)
- Sound effects
- Load word list from external file
- Show stats
- "Play again" option
- Unit tests
Pull requests are welcome!
Open an issue if you want to suggest improvements or report bugs.
This project is licensed under the MIT License.
See the LICENSE file for details.
Ali Bahrami
GitHub: https://github.com/AliBahrami-ce
