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:

def play_game():

    # Pick word randomly from list
    random_num = random.randint(0, (len(words_list) - 1))
    current_word = list(words_list[random_num].upper())
    print(current_word)
    print('The word has', str(len(current_word)), 'characters')

    current_letter = input('Pick a letter: ').upper() #User input
    picked_letters = []
    correct_ones = []
    for i in range(len(current_word)):
        correct_ones.append('_ ')

    lifes = 3
    while lifes != 0:

        # Check if all characters have been already guessed
        if current_word == correct_ones:
            print('You won!')
            break

        # Check if character has already been chosen
        elif current_letter in picked_letters:
            print('You already chose this letter!')
            current_letter = input('Pick another letter: ').upper()
            continue

        # Check if character is in word
        if current_letter in current_word:
            index_list = []
            for i in range(len(current_word)): #Get indexes of character in word
                if current_word[i] == current_letter:
                    index_list.append(i)

            picked_letters.append(current_letter) #Append to keep track of chosen characters         
            for i in index_list:
                correct_ones[i] = current_letter.upper() #Append to correct position

            print('Correct!')
            for i in correct_ones:
                print(i + ' ', end='')
            current_letter = input('Pick another letter: ').upper()

        # Incorrect character
        else:
            picked_letters.append(current_letter)
            lifes -= 1
            print('Incorrect')
            print('You have', str(lifes), 'lifes left')
            current_letter = input('Pick another letter: ').upper()
            continue


play_game()

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:

import random

choice = None

list = ["HANGMAN", "ASSIGNEMENT", "PYTHON", "SCHOOL", "PROGRAMMING", "CODING", "CHALLENGE"]
while choice != "0":
    print('''
    ******************
    Welcome to Hangman
    ******************

    Please select a menu option:

    0 - Exit
    1 - Enter a new list of words
    2 - Play Game

    ''')
    choice= input("Enter you choice: ")

    if choice == "0":
        print("Exiting the program...")
    elif choice =="1":
        list = []
        x = 0
        while x != 5:
            word = str(input("Enter a new word to put in the list: "))
            list.append(word)
            word = word.upper()
            x += 1
    elif choice == "2":
        word = random.choice(list)
        word = word.upper()
        hidden_word = " _ " * len(word)
        lives = 6
        guessed = []

        while lives != 0 and hidden_word != word:
            print("\n******************************")
            print("The word is")
            print(hidden_word)
            print("\nThere are", len(word), "letters in this word")
            print("So far the letters you have guessed are: ")
            print(' '.join(guessed))
            print("\n You have", lives,"lives remaining")
            guess = input("\n Guess a letter: \n")
            guess = guess.upper()
            if len(guess) > 1:
                guess = input("\n You can only guess one letter at a time!\n Try again: ")
                guess = guess.upper()
            while guess in guessed:
                print("\n You have already guessed that letter!")
                guess = input("\n Please take another guess: ")
                guess = guess.upper()
            guessed.append(guess)
            if guess in word:
                print("*******************************")
                print("Well done!", guess.upper(),"is in the word")
                word_so_far = ""
                for i in range (len(word)):
                    if guess == str(word[i]):
                        word_so_far += guess
                    else:
                        word_so_far += hidden_word[i]
                hidden_word = word_so_far
            else:
                print("************************")
                print("Sorry, but", guess, "is not in the word")
                lives -= 1

        if lives == 0:
                print("GAME OVER! You ahve no lives left")
        else:
            print("\n CONGRATULATIONS! You have guessed the word")
            print("The word was", word)
            print("\nThank you for playing Hangman")
    else:
        choice = input("\n That is not a valid option! Please try again!\n Choice: ")