This is a console-based implementation of the classic hangman game using Python. Players can guess letters to uncover a hidden word within a limited number of attempts.
- Run the Python script hangman.py.
- You will be presented with a question or a clue related to the word to guess.
- Enter a letter as your guess and press Enter.
- The game will display the current state of the word, indicating if your guess was correct or incorrect.
- If your guess is correct, the corresponding letters will be revealed in the word.
- If your guess is incorrect, a part of the hangman figure will be displayed.
- Keep guessing letters until you either guess the word correctly or run out of attempts.
- If you guess the word correctly, you win the game.
- If you run out of attempts before guessing the word, you lose the game.
- After each game, you can press Enter to continue to the next question.
Use the keyboard to enter a single letter as your guess. Press Enter after entering your guess.
Python 3.x
Clone this repository to your local machine or download the files as a ZIP archive. Open a terminal or command prompt and navigate to the project directory.
Run the following command to start the game:
python hangman.py
The game uses a JSON file (data.json) to store the questions and associated words. You can customize the questions and words by modifying this file. Each question and word pair should be in the following format:
{
"question_id": ["word_to_guess", "question"]
}
- question_id: A unique identifier for the question.
- word_to_guess: The word that needs to be guessed.
- question: A clue or question related to the word.
- You can add or remove question entries as desired.
This project is licensed under the MIT License. Feel free to contribute, report issues, or suggest improvements!