The Hangman Project

Víctor López

Description and Rules of the game

Classical "Hangman" with a country thematic.

Description

There are a few and simple rules:

  • 10 maximum failures.
  • The input can only be letters from A-Z and blank space (" ").
    • Empty space ("") or more than one character is not allowed.
    • Exception: You can also type 1, but this will stop the game.

Rules

Workflow

The workflow was the following:

  1. Research the rules of the game.
  2. Pseudocode the game structure.
  3. Research code of the game to see if I'm on a good path.
  4. First meeting with TA.
  5. Coding and testing.
  6. Second meeting with TA.
  7. Polish the code.

Challenges

The most notable challenge was the replacement process.

 

When the player inputs a letter, if that letter is part of the hidden word, I had to replace the dash with the proper letter. It was the first time that I had to replace strings from inputs. 

 

Although I found the function enumerate, I didn't understand how to use it properly. The TA helped me out in building this part.

Learnings

Some learnings of that project might be:

  • If you print(input()) some conditions, like len(), will run into an error. 
  • The function time.sleep can solve some aesthetic parts of the code.
  • Print every time you code to see if the output is what you expected.
  • While coding, create a variable that allows you to stop the loop faster.
  • Indent properly on loops to avoid fail printing.
  • Set more than one condition on while loops.

Possible future improvements

For the future, I might improve the following parts:

  • Set the word exit for stopping the loop. 
  • The countries list has been written manually. 
  • The allowed_characters list has been written manually.
  • If the player knows (or wants to try his/her luck), let it guess the word. If it's the hidden word, it wins automatically; if not, it loses.

Demo of the game

Thank you!

Made with Slides.com