As part of Codecademy’s Computer Science 101 course, I recently built a simple Hangman game in Python. While it’s a beginner project, it was a great opportunity to practice structuring code, handling user input, and managing game logic.
The game follows the classic Hangman rules:
The program selects a random word from a predefined word bank.
The player guesses letters one at a time.
If they guess correctly, the letter is revealed in the word.
If they guess incorrectly, they lose a life.
The game ends when the player either guesses the word or runs out of lives.
I structured the game using a HangmanGame class to manage game logic, along with a separate WordBank class to handle word selection based on difficulty.
One challenge was refactoring my initial script into a class-based structure. At first, I had everything in a single procedural script, which made it harder to manage. Breaking it into classes improved organization and made future updates easier.
I also learned a lot about handling user input, ensuring invalid inputs don’t break the game flow. This project was a great first step, and while I know I have a long way to go in my coding journey, I’m happy with the progress so far.
If you’re interested in checking out the code, you can find it here: https://github.com/mDex2409/CS101Hangman.
Top comments (1)
Seem like Repo does not exist.