The assignment is to have an input: "chose a word" from a list if "cat" is given by the user, then I want every word that have: ca_, c_t, _at to be printed out (except cat) and words cant repeat so for example if "car" is in the list twice it should only be printed once. I started with the code but cant manage to finish
def build(wordList):
dict = {}
for i in wordList:
for j in range(len(i)):
bucket = i[:j] + '_' + i[j+1:]
if bucket in dict:
dict[bucket].append(i)
else:
dict[bucket] = [i]
return dict