1def edits1(word):
2 splits = [(word[:i], word[i:]) for i in range(len(word) + 1)]
3 deletes = [a + b[1:] for a, b in splits if b]
4 transposes = [a + b[1] + b[0] + b[2:] for a, b in splits if len(b)>1]
5 replaces = [a + c + b[1:] for a, b in splits for c in alphabet if b]
6 inserts = [a + c + b for a, b in splits for c in alphabet]
7 return set(deletes + transposes + replaces + inserts)
8