Skip to main content

Command Palette

Search for a command to run...

Day 2: Hangman

Published
2 min read
Day 2: Hangman
A

Hi there! I’m a passionate learner who loves exploring Python's endless possibilities. Over the past years, I’ve immersed myself in coding, honing my skills by tackling diverse projects that combine creativity and problem-solving.

From building a modern rendition of the classic Asteroids game in Python to experimenting with data visualization and automation, I thrive on turning ideas into reality through code.

Follow along as I learn, grow, and share my journey!

pexels-cottonbro-4065879.jpg Today, I spent learning a couple of key skills:

  1. Breaking Down A Complex Problem A classic Computer Science skill is problem reduction. Taking a large problem and solving many smaller problems is a key problem solving technique. Divide and Conquer. The Hangman problem at first seemed daunting but by breaking the problem down into solvable smaller problems - it turned out to not be that bad after all.

  2. Getting Input Using input() in Python couldn't be easier. You just need to remember that you always get back a string - even when you think you have a number - so if you need a number - remember to convert.

  3. Using Arrays Using arrays with for loops was a great way to solve this problem as we had to display the slots to the user so they would know where their letters were ending up in relation to the words length and missing characters.

  4. Having a termination condition This part was critical making all the difference between an infinite loop and a game that recognizes when you've won or lost. Making this check made the logic easier to follow when making a while loop that hinged on whether we should continue or just end this dance right now. Once this mechanism was established then we could add to it by keeping number of lives.

  5. User Experience Having even something as simple as ASCII art makes the experience of the game so much better. Putting in a logo and an array of ASCII art was an easy way to get UX bang for the buck.

Daily practice is going to really improve my skill at this. To play Hangman - you can visit my game at: https://replit.com/@AllieNicole/hangman/

#100DaysOfCode

Follow me on Twitter at AllieNicole903