A small, beginner-friendly word guessing game implemented in Python. The game offers two play modes: a GUI version using Tkinter and a simple terminal (CLI) version. You have 6 lives to guess the word, and incorrect guesses reduce your remaining lives.
- Simple and portable Python code.
- GUI built with
tkinterand uses images for the hangman states. - Terminal mode included for quick play and testing.
- Python 3.8+ (tested with Python 3.11)
- Pillow (for GUI image handling)
Install the required package:
pip install pillow- Clone or download the project and open the project folder.
- Ensure
words.txtcontains the words you want the game to choose from (one or more words separated by whitespace).
GUI (Tkinter)
- Run the GUI app:
python app.py- A window will open showing the hangman image, blank spaces for the word, and letter buttons. Click letters to guess. The game ends when you guess the word or run out of lives.
Terminal (CLI)
- Run the module directly:
python hangman_init.py- Follow the prompts in the terminal to guess single letters.
app.py— GUI entry point usingtkinterandPillow.hangman_init.py— Game logic and terminal gameplay loop.words.txt— Word list used by the game (one or more words separated by spaces/newlines).images/— PNG images for hangman states (0..6) used by the GUI.README.md— This file.
- Edit
words.txtto add or remove words. Each word can be separated by spaces or new lines. The game picks random words from this file.
- For best results in the GUI, keep the
imagesfolder intact with the required0.pngthrough6.pngimages. - The code is lightweight and intended for learning; feel free to refactor or enhance (difficulty levels, scoring, save/load, multiplayer, etc.).
- Small fixes, improvements and images are welcome. Open a PR or edit locally and commit.
- This repository has no explicit license file. If you plan to share it publicly, consider adding an OSI-compatible license (for example, MIT) to clarify reuse terms.