A simple console-based Hangman game written in Python. This game allows the player to guess letters in a randomly selected word until they either guess the word correctly or run out of attempts.
- Random Word Selection: A word is randomly chosen from a predefined list.
- Letter Guessing: Players guess letters to reveal the word.
- Incorrect Guesses Tracking: Tracks incorrect guesses and limits the number of allowed incorrect guesses.
- Win/Loss Conditions: The game ends when the player either correctly guesses the word or exhausts the allowed number of incorrect guesses.
Ensure you have Python installed. This game does not require any additional libraries.
-
Clone the repository or download the code:
git clone https://github.com/yourusername/hangman-game.git
-
Navigate to the project directory:
cd hangman-game
To start the game, run the following command in your terminal:
python hangman.py
- The game will display underscores representing the letters in the word.
- Input a single letter to guess.
- The game will update the display based on correct or incorrect guesses.
- The game ends when you either guess all the letters in the word or run out of attempts.
Welcome to Hangman!
_ _ _ _ _ _
Guess a letter: a
Good guess!
_ _ a _ _ _
Guess a letter: e
Incorrect! You have 5 attempts left.
_ _ a _ _ _
Guess a letter: s
Good guess!
_ _ a s _ _
...
Congratulations, you won!
- Add More Words: Update the
WORDS
list in thehangman.py
file with additional words. - Improve UI: Enhance the user interface or add graphical elements by integrating with libraries like Pygame.
- Add Difficulty Levels: Implement difficulty levels by categorizing words into easy, medium, and hard.
Feel free to fork the repository and submit pull requests with improvements or fixes. Please follow the coding style and guidelines provided in the code.
This project is licensed under the MIT License. See the LICENSE file for details.