Q:

Storing the guessed word in Hangman game

How can I store the users input from the hangman function, so every time the for loop runs it remembers the user has already guessed the letter. 
When the hangman function runs the first time, if the user's input is 'gera', that's fine, it should then loop back for a fifth guess; the problem is if the user enters 'mo' now, it won't show like this gera _ _ mo, instead it'll print _ _ _ _ _ _ mo; forgetting the users previous 'gera' input. 
How can I store past inputs so the code recalls what was passed?
def get_guessed_word(secret_word, letters_guessed):

    a = ""
    for char1 in secret_word:
        if char1 in letters_guessed:
                a += char1
        else: 
                a += "_ "

    print(a)

def get_available_letters(letters_guessed):

    a = string.ascii_lowercase
    for char1 in a:
        if char1 in letters_guessed:
           a = a.replace(char1,"")

    print(a)

def hangman(secret_word_user_to_guess):

    secret_word_user_to_guess = 'geranimo'

    for index in range(6,1,-1):
        print('You have', index,'guesses left.')
        #print('Available letters: abcdefghijklmnopqrstuvwxyz')
        letters_guessed = input('Check a word: ')
        get_guessed_word(secret_word_user_to_guess, letters_guessed)
        print('Available letters:')
        get_available_letters(letters_guessed)

A:

You can do this easily:
result = ""
for char in secret_word:
    if char in letters_guessed:
        result += char
    else:
        result += "_"

Or, using a generator:
result = "".join(char if char in letters_guessed else "_" for char in secret_word)

BTW, letters_guessed could be a string ("eikprs") or, if the order doesn't matter, a set: set("eikprs").

You can also try this:
result = secret_word.translate("".maketrans(letters_guessed, "_" * len(letters_guessed)))

