for j, word in enumerate(data):
    if word[:-1] == data[count][:-1] and j != count:
        matches[data[count]] = word
temp_data.remove(data[count])
temp_data.remove(word)
Regex: Efficiently matching words that are the same except for last character