RiderExMachina,

Having the output of each thing you tried would help us get a feel for where your code was messing up without us having to run it ourselves to get the output.

That said, for code snippet 1, you’re inserting the letter instead of replacing the underscore with the letter. Not only that, but your for-loop essentially does the following:

  • loop over the length of chosen_word
  • if guess is in the above loop
    • iterate over the display array and add guess that many times (effectively doubling the `display array)

Your second code snippet does the same thing, but with actual formatting so that Python could run the code.

I believe your third code snippet introduces char but then returns to letter. It might work if you replaced char with letter again. Also += letter will add the letter to the end of display, which is not what you want to do.

I did my own version of Hangman in Python a couple years ago if you want to look at the code and see what I did. I’m just a hobbyist, so it’s not fantastic, but it might give you an idea of how someone else has approached the problem.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • [email protected]
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • Socialism
  • KbinCafe
  • TheResearchGuardian
  • Ask_kbincafe
  • oklahoma
  • feritale
  • SuperSentai
  • KamenRider
  • All magazines