Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

🎮 Hangman — Terminal Edition

A feature-rich console implementation of the classic Hangman game, built in pure Python with no external dependencies required (colors are optional via colorama).

========================================================
| 🎮  H A N G M A N  🎮
| Guess the word before time runs out!
========================================================

✨ Features

Feature Description
💡 Categories Words are tagged with emoji categories (Fruit, Animal, Sport, Tech, etc.)
🎯 Difficulty levels Easy / Medium / Hard — changes lives and word length
❤️ Lives system Visual life bar that shrinks with each wrong guess
📈 Progress bar Shows how much of the word you've uncovered
💭 Hints A one-time hint becomes available after 3 wrong guesses
🏆 Session statistics Tracks games played/won/lost, win rate, best score, and streaks
🎲 Random messages Varied flavor text for correct guesses, wrong guesses, wins, and losses
🔄 Play again Keep playing multiple rounds in one session
🎨 Smart coloring Auto-detects your environment and enables colors only where they'll render correctly

📦 Requirements

  • Python 3.8 or newer
  • (Optional, for colored output) colorama

Install colorama with:

pip install colorama

The game runs perfectly fine without colorama — it just won't have colored text.


🚀 How to Run

Option 1 — Command Prompt / PowerShell (recommended, supports colors)

  1. Open Command Prompt or PowerShell.
  2. Navigate to the folder containing the script:
    cd "path\to\your\folder"
  3. Run the game:
    python hangman.py
    If that doesn't work, try:
    py hangman.py

Option 2 — IDLE (works, but no colors)

You can also open and run the file directly in Python's IDLE editor (F5 or Run → Run Module). Colors will be automatically disabled since IDLE's Shell doesn't support ANSI color rendering — everything else works the same.

Note: This is a limitation of IDLE itself, not the game. For the full colored experience, use a real terminal as shown in Option 1.


🕹️ How to Play

  1. Choose a difficulty level:
    Level Lives Word length
    1 — Easy 🟢 8 3–5 letters
    2 — Medium 🟡 6 6–7 letters
    3 — Hard 🔴 4 8–12 letters
  2. Guess one letter at a time.
  3. Correct letters reveal their position(s) in the word and add to your score.
  4. Wrong letters cost you a life and grow the gallows drawing.
  5. After 3 wrong guesses, you'll be offered an optional one-time hint.
  6. Win by revealing the whole word before you run out of lives.
  7. At the end of each round, your session statistics are shown, and you can choose to play again.

🗂️ Project Structure

hangman.py    → Main game script (single file, no external files needed)
README.md     → This documentation

🛠️ Technical Notes

  • Written entirely in the Python standard library, plus optional colorama for cross-platform color support.
  • Uses dataclasses for clean statistics tracking.
  • Auto-detects whether it's running inside IDLE (idlelib in sys.modules) and disables ANSI colors there, since IDLE doesn't interpret them.
  • All functions are single-responsibility and documented with docstrings for readability and easy extension.

🤝 Contributing / Extending

Ideas for extending the game:

  • Add a timer per guess for extra challenge.
  • Add multiplayer (take turns guessing).
  • Load word lists from an external JSON/CSV file instead of hardcoding them.
  • Add a "custom word" mode where a second player sets the word.

📄 License

Free to use, modify, and share for learning and personal projects.

About

A Python-based Hangman Game developed for the CodeAlpha Python Programming Internship.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages