DEV Community

Cover image for Building a Hangman Game in Python - With a Linguistic Twist!
eglasb
eglasb

Posted on

Building a Hangman Game in Python - With a Linguistic Twist!

In_r_duc_i_n

   ________
   |/     |
   |     ___
   |    |ó,ò|
   |    \_-_/
   |      
   |
   |
Enter fullscreen mode Exit fullscreen mode

Ever wanted to learn Portuguese while playing a classic game? Well, you might not become fluent, but playing my Hangman (Forca) game in Portuguese will at least teach you some words — and test your guessing skills! As part of my Python learning journey, I decided to build a Hangman game in the terminal. This project helped me understand concepts like string manipulation, loops, and object-oriented programming while having fun. The ideia was to make it a very polished experience, without unexpected crashes, counting games and victories, calling the player by the name.

The Project "Forca"

Image description
Prepare for gruesome death!

Image description
And Victory!

For this project I´ve created 4 classes and a utility file:

  • Game - manages game flow
  • Player - manages player data (lives, letters played, etc.)
  • SecretWord - deals with word management and revealing letters
  • HangmanDoll - holds the ASCII art.
  • utils.py - contains some shared functions for reading file, clearing screen and input validation I tried to use a modular approach and type hints to really exercise OOP.

It was a great learning experience and I think the game turned out to be really funny to play!

I used Python in VScode for the entire game logic and Git for version control.

Code on GitHub

https://github.com/eglasb/Forca.git

Future improvements

I intend to eventually add a GUI. Maybe Pygame?

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more