Python Forum
hangman doesn't end after guessing the word
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hangman doesn't end after guessing the word
#3
The code works. The problem is that it doesn't work as it's supposed to work when the word contains letters which repeat themselves, as I've already stated.
I've just found the solution, though. Instead of using list the conditional, I should use set, and then a word like 'blueberry' works fine:
if len(good_guesses) == len(set(secret_word)):
P.S. to be more explicit, if a word like 'blueberry' is chosen, then the program will never exit, you keep guessing and you're going to be kept in a loop.
Reply


Messages In This Thread
RE: hangman doesn't end after guessing the word - by vinci - Nov-06-2019, 09:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Hangman Troubleshooting Ewilliam51 5 3,131 Jul-22-2020, 07:09 AM
Last Post: Sooqa
  fun with hangman! Low_Ki_ 7 7,038 Jun-13-2017, 05:03 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020