A simple command-line Hangman Game built using Python. The player has to guess a randomly selected word one letter at a time. The player gets 6 chances to guess the word correctly.
This project is beginner-friendly and demonstrates important Python concepts such as loops, conditional statements, lists, strings, user input, and the random module.
The Hangman Game randomly selects a word from a predefined list. The selected word is initially displayed as underscores (_).
The player enters one letter at a time. If the letter exists in the word, it is revealed in its correct position. If the letter is incorrect, the player loses one chance.
The game continues until:
- 🎉 The player correctly guesses the complete word, or
- 💀 The player uses all 6 chances.
- 🎲 Random word selection
- 🔤 Letter-by-letter guessing
- ❤️ 6 chances for each game
⚠️ Prevents repeated letter guesses- ✅ Displays correct guesses
- ❌ Shows remaining chances after wrong guesses
- 🎉 Win detection
- 💀 Game-over detection
- 🖥️ Simple command-line interface
- Python 3
randommodule- Lists
- Strings
whileloopforloopif-elseconditions- User input
Hangman-Game/
│
├── hangman.py
└── README.md
git clone https://github.com/your-username/Hangman-Game.gitcd Hangman-Gamepython hangman.py- Start the Python program.
- A random word will be selected automatically.
- The word will be displayed using underscores.
- Enter one letter at a time.
- If your guess is correct, the letter will be revealed.
- If your guess is wrong, you lose one chance.
- You have a maximum of 6 wrong guesses.
- Guess the complete word before your chances run out to win.
🎮 Welcome to Hangman Game!
Guess the word letter by letter.
Word: _ _ _ _ _ _
Enter a letter: p
✅ Correct guess!
Word: p _ _ _ _ _
Enter a letter: y
✅ Correct guess!
Word: p y _ _ _ _
Enter a letter: z
❌ Wrong guess! Chances left: 5
Word: p y t h o n
🎉 Congratulations! You guessed the word: python
❌ Wrong guess! Chances left: 0
💀 Game Over! The word was: programming
The random.choice() function selects one word from the predefined list:
words = ["python", "developer", "hangman", "programming", "computer"]
word = random.choice(words)The selected word is represented using underscores:
display_word = ["_"] * len(word)The player enters a letter:
guess = input("Enter a letter: ").lower()The program checks whether the guessed letter exists in the selected word.
If the guess is correct, the corresponding position in the hidden word is revealed.
For every incorrect guess, the number of chances decreases by one.
The game checks whether:
- All letters have been guessed → Player wins 🎉
- Chances reach zero → Player loses 💀
This project helps beginners understand:
- Random number/module usage
- Lists
- String operations
- User input
if,elif, andelsewhileloopsforloops- Conditional logic
- Basic game development
- Managing game state
The game can be improved by adding:
- 🖼️ ASCII Hangman graphics
- 📚 Larger word dictionaries
- 🎯 Difficulty levels
- 🏆 Score system
- 🔄 Play-again option
- ⏱️ Timer
- 👥 Two-player mode
- 💡 Hint system
- 🏅 High-score tracking
- 🖥️ Graphical User Interface using Tkinter
The main objective of this project is to build a simple interactive game while practicing fundamental Python programming concepts.
It is suitable for:
- Beginners learning Python
- College mini-projects
- Python practice
- GitHub portfolios
- Understanding loops and conditional statements