I'm trying to understand an iterative function that that takes a string "12345" and returns all the possible misspellings based upon a dictionary of keys close to each character in the string.
outerDic = {}
Dict1 = {'1':'2','2':'q'}
outerDic['1'] = Dict1
Dict1 = {'1':'1','2':'q','3':'w','4':'3'}
outerDic['2'] = Dict1
Dict1 = {'1':'2','2':'w','3':'e','4':'4'}
outerDic['3'] = Dict1
Dict1 = {'1':'3','2':'e','3':'r','4':'5' }
outerDic['4'] = Dict1
Dict1 = {'1':'4','2':'r','3':'t','4':'6' }
outerDic['5'] = Dict1
outerDic
The output should return a list of strings
12345
22345
q2345
11345
1q345
13345
12245
12e45
12445
and so on...
I've set the function up as follows:
def split_line(text):
words = text.split()
for current_word in words:
getWordsIterations()
I'd like to understand how to set up the getWordsIterations () function to go through the dictionary and systematically replace the characters.
Thanks in advance, kind of new to pythong.