'Hangman With Hints. What's wrong with my hint function?

I'm working through MIT 6.0001 intro to python programming class online. It's suffering and (occasionally) joy. PSet 2 is to make hangman with more and more functions, ending with hints, printing each possible solution left to the player. PSB for the link to the problem sets (This one is: Link -> PSet 2 -> PDF Document -> Page 10)

https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/assignments/

I can't find the important difference between mine that doesn't work and a github solution that does.

Mr(s) Github removes spaces from guessed_word and potentially mathcing words containing letters from letters_guessed string. I haven't yet because my code already doesn't work regardless of this.

We're both using a for loop that checks words in the words list for possible matches to our guessed word (so far), giving a pass to blank letters ('_'), returning True for possible matches, False if not.

Another function adds any True words to a possible_matches list and prints the list.

Please help spot the issue. I've been pulling my hair out for days over this.

GitHub solution relavant 2 modules begin at line 195, link below. Mine are copied and pasted just below that.

https://github.com/danemauland/MIT-OCW-6.0001-PS2/blob/master/hangman.py

word_list = ['baba', 'bebe', 'bobo', 'booboo']
my_word = 'baba'


def match_with_gaps(my_word, other_word):

    '''
    my_word: string with _ characters, current guess of secret word
    other_word: string, regular English word
    returns: boolean, True if all the actual letters of my_word match the 
        corresponding letters of other_word, or the letter is the special symbol
        _ , and my_word and other_word are of the same length;
        False otherwise: 
    '''

            
    for other_word in word_list:
        if len (other_word) != len (my_word):
            return False
        else:
            for i in other_word:
                if i in other_word != i in my_word and i in my_word != '_':
                    return False
        return True

def show_possible_matches(my_word):

    '''
    my_word: string with _ characters, current guess of secret word
    returns: nothing, but should print out every word in wordlist that matches my_word
              Keep in mind that in hangman when a letter is guessed, all the positions
              at which that letter occurs in the secret word are revealed.
              Therefore, the hidden letter(_ ) cannot be one of the letters in the word
              that has already been revealed.

    '''
    possible_matches = ''
    for other_word in word_list:
        if match_with_gaps(my_word, other_word):
            possible_matches += other_word,
    print(possible_matches)
        
show_possible_matches(my_word)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source