Anirudha
← Work
15 Days of CodingDay 7September 16, 2025~5 min read

Hangman Game

Break down huge problems in small tasks

Its been 7 days of learning. I think so far, it is the best way of learning for me. Understanding a small concept each day and then practically implementing it has made me more confident than when I completed a course on CourseEra.

Today, I focused on developing a game called “Hangman”. If you are not familiar with the game, I will walk you through it. The player has 6 lives and the goal of the game is to guess a random word which is generated every game. The player guesses a letter each round and if the letter is a part of the word, the blank gets filled in, and the player retains their life. If the guessed letter is not a part of the word, the player loses a life. The player wins if he guesses the word correctly before losing all their lives. The player loses if they lose all their lives after 6 incorrect guesses.

Since I decided to implement the game from scratch, I sketched a flow chart of the game and what each step should be inside the code. After my first draft, I walked through the flow chart and had to make a few minor adjustments regarding the lives remaining and when should the game be over. This flow chart became the foundation for me to implement the code in Python. Each block in the flow chart became a task for me to complete before moving onto the next block.

This is where my insight for the day came from. To always break big tasks into smaller ones so that you can accomplish them easily and you get a start and build momentum. It gets really difficult to start when you have a big task in front of you and often you can’t even figure out where to start and you just end up procrastinating and giving up.

First, I started by building a word list of a couple of words which were to be picked randomly for each new game. Since this was my demo and I just wanted to see if my logic works, I decided to print the random word so I can check for any mistakes. Then, I asked the user to guess a letter and started checking if this letter is a part of the chosen random word. If it is, I wanted the code to print out correct and if it was not, to print out wrong. Because of this, I understood if the basic logic for the game works.

For the user to understand how the game is progressing and if they are winning or losing, I introduced a variable with blank character equal to the length of the random word. If the guessed letter was a part of the word, I started filling the blank character at the appropriate space of the random word. This started helping the user to understand where their guessed letter is in the random word which help them make their next guess with more knowledge. But since I was only using the if loop to check if the guessed letter is a part of the random word, the player could only guess one letter and the game stopped. So I decided to implement a while loop to make the player keep guessing until all the blank characters were filled. Once all the blank characters were filled, this means the player guessed the random word and the player wins. At this point of the code, there was no way the player can lose and basically had unlimited tries to win the game.

To make the game playable, I introduced the variable lives and added a condition on making the player lose their lives if they guessed the wrong letter. If the lives went to 0, the game got over and the player lost. This balanced the game and gave the player equal opportunity to either win or lose.

Once this basic implementation was done, I focused on the user experience. I imported a bigger word list from which the random words were generated. Imported sketches for the game using ASCII characters including the logo and one sketch for each round and sketches for each life lost. Also printed out the correct word for the player if they lost so at least they can know where they went wrong.

This was the longest time I had coded continuously and it took me more than 2 hours to finish this game. I had to debug, problem solve and figure out the next steps and I used online resources generously. No ChatGPT or Cursor yet though. The main reason I am doing this is to understand how coding works and not just copy paste code. So I will hold off on all AI tools for now. I had a lot of fun figuring everything out and if you want to try the game too, please hit me up. Until tomorrow!