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