def update_guess_word(word, guess_word, guess):
    """
    Updates the guess_word with the newly guessed letter.

    By iterating over the word and comparing each character, we can find
    all occurences of that letter and can replace the underscores in the
    guess word for each found occurence.

    E.g. if the word is 'hello' and the guess_word was ['_', 'e', '_', '_', '_']
    and the guess was 'l', the result will be ['_', 'e', 'l', 'l', '_']

    The function modifies the list in place.

    Args:
        word: the target word
        guess_word: the current state of the guess word
        guess: the guessed letter
    
    Returns:
        the updated state of the guess word. Though unnecessary, since lists
        are passed by reference and altered directly.
    """
    for i, letter in enumerate(word):
        if letter == guess:
            guess_word[i] = letter

    return guess_word