Hướng dẫn hangman python stack overflow
I just wrote a functioning program to play Hangman game, but there's one issue that's bothering me which I haven't been able to figure out. The program correctly asseses whether the chosen character is in the word to be guessed, as well as its position in the word (even if the character appears more than once). Nonetheless, when playing the game it takes one more turn than needed to asses whether you guessed the word completely, or whether you have no lifes left. Say, for example, you have to guess the word 'hello'. I would expect to program to run like: Turn 1: 'h'. Turn 2: 'e'. Turn 3: 'l'. Turn 4: 'o'. The program should stop here, but it needs another character (any) to recognize that the game has been completed. Here's my code:
If you see any bad practice in my code feel free to tell me so! Thanks in advance! For an assignment I need to write a basic HANGMAN game. It all works except this part of it... The game is supposed to print one of these an underscore ("_") for every letter that there is in the mystery word; and then as the user guesses (correct) letters, they will be put in. E.G Assuming the word was "word" User guesses "W" W _ _ _ User guesses "D" W _ _ D However, in many cases some underscores will go missing once the user has made a few guesses so it will end up looking like: W _ D instead of: W _ _ D I can't work out which part of my code is making this happen. Any help would be appreciated! Cheers! Here is my code: |