https://github.com/hsur05/python_guessing_game
Python Hangman game for CS50 class
https://github.com/hsur05/python_guessing_game
debugging-tool if loops python
Last synced: 11 months ago
JSON representation
Python Hangman game for CS50 class
- Host: GitHub
- URL: https://github.com/hsur05/python_guessing_game
- Owner: hsur05
- Created: 2025-02-18T00:37:08.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-21T03:42:52.000Z (about 1 year ago)
- Last Synced: 2025-03-28T17:35:42.800Z (about 1 year ago)
- Topics: debugging-tool, if, loops, python
- Language: Python
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Word Guessing Game
Welcome to my hangman game!- a simple command-line word guessing game built with Python. Players have 5 attempts to guess a randomly selected word by suggesting letters one at a time.
## How to Play
1. The game randomly selects a word from its vocabulary
2. You get 5 attempts to guess the word
3. Enter one letter at a time
4. If your guess is correct, all instances of that letter are revealed
5. If your guess is incorrect, you lose an attempt
6. You win by correctly guessing all letters in the word
7. You lose if you run out of attempts
## Features
- Random word selection from a predefined vocabulary
- Input validation for letter guesses
- Tracking of previously guessed letters
- Visual representation of word progress using underscores
- Game ends when the player wins or runs out of attempts
## Requirements
- Python 3.x
## Installation
1. Clone this repository or download the `project_final.py` file
2. No additional dependencies are required
## Usage
Run the game using Python:
```bash
python project_final.py
```
## Game Mechanics
- Words are randomly selected from a predefined list
- Each letter is represented by an underscore "_"
- Correctly guessed letters replace their corresponding underscores
- The game tracks letters you've already guessed
- You cannot guess the same letter twice
## Word List
The game includes the following words: (You can add as many as you like!)
- test
- obfuscate
- funny
- computers
- coding
- python
- matrix
- programming
- iphone
- macbook
- screen
## Example Gameplay
```
_ _ _ _ _ _
Enter an alphabet: a
letters used so far: ['a']
This letter is not in the word! You have 4 attempts left.
Enter an alphabet: p
letters used so far: ['a', 'p']
p _ _ _ _ _
Enter an alphabet: y
letters used so far: ['a', 'p', 'y']
p y _ _ _ _
...
Congratulations! You got the word!
```
## Customization
To add more words to the game, edit the `vocab` list in the `select_vocab()` function.
## License
This project is available for open use.
## Author
Roy Hsu
## Acknowledgments
Inspired by the classic Hangman game