for i in range(1, len(word1)):
    if word1[i] != word2[i]:
        if same:
            same = False
else:
    return False
return not same
How can I optimize this Python code to generate all words with word-distance 1?