I created this hangman game today as my first stand alone project. It is a quite basic and simplified approach. How could I improve the game to make it more interesting?

    import random
    words = ["abductions", "abridgment", "admixtures"
    ,"backfields", "blueprints", "chivalrous", "complexity", "cyberpunks", "desolating", 
     "truckloads","upholstery","vanquished","vulcanizes","wanderlust","womanizers" ]

      i = random.randint(0, len(words) - 1)

      word = words[i]
      guesses = "_"*len(word)
      lives = 0
      while lives < 5:
         character_check = input("")
           if character_check in word and character_check != word:
               a = word.index(character_check)
               guesses = guesses[:a] + word[a] + guesses[a+1:]
           if guesses == word or character_check == word:
           elif character_check not in word:
               lives += 1
    if lives == 5:
      print("You lose! It was {}".format(word))

2 Answers 2


This is a great start. Let me point out a few things you should consider.

Make it interactive

When I ran the code, it produces some numbers whenever I lose a guess, it took a while to figure out that it was my guess count incrementing. A nice prompt message would be helpful. Also the guess count should reduce for each guess made.

Avoid hardcorded values

What is 5 in the following statement while lives < 5:. it can be written as follow

while lives <= MAX_LIVES:

Misleading names

character_check is just too misleading, promises one thing(to check a character) and does another thing(recieves input from the user). This can rewritten as user_input

Features worth adding

  1. You could make the game a class,implement a board class to nicely draw the man being hung.
  2. You could also implement a hint package interface, user might want to buy and use hints when they are stuck.
  • 1
    \$\begingroup\$ Thanks! I have since changed a couple things already. I did notice afterwards that the lives should have been decreasing not increasing, I had like a D'oh moment. I like the idea for hints, I'll try to incorporate that. \$\endgroup\$
    Nov 19, 2020 at 19:13

A couple of coding suggestions...

  1. You can use random.choice(words) to pick a random item out of the words list.

  2. I'd be tempted to sys.exit() instead of break on winning. That way you don't need to test the value of lives - if you reach the end of the while loop you have lost.

In terms of making the program 'more interesting', I'd add a welcome message, maybe explain the rules. Maybe also display a list of letters already guessed and do nothing if the same letter is guessed twice? (Right now choosing the same letter 5times loses the game). you could also have short, medium and long (or easy, medium, hard) word lists and ask the person to choose which they want to use.

  • \$\begingroup\$ Thanks! I'll try to implement those things as soon as possible \$\endgroup\$
    Nov 19, 2020 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.