对于拼写检查器,我想在拼写中添加两个缺失的字母。请建议我如何在python中做到这一点。我有添加一个字母的代码。
def splits(word):
result = []
for i in range(len(word) + 1):
result.append((word[:i], word[i:]))
print result
return result
def inserts(word):
result = []
for a, b in splits(word):
for c in alphabet:
result.append(a + c + b)
return result
例如,我有话He
我想要结果Haeb
,aHeb
等abHe