Find next word in dict by changing each element from ' a ' to 'z
' NEW_LINE INDENT for i in range ( len ( wrd ) ) : NEW_LINE INDENT s = wrd [ i ] NEW_LINE c = ' a ' NEW_LINE while c <= ' z ' : NEW_LINE INDENT wrd [ i ] = c NEW_LINE if ' ' . join ( wrd ) in Dict : NEW_LINE INDENT res . append ( ' ' . join ( wrd ) ) NEW_LINE DEDENT c = chr ( ord ( c ) + 1 ) NEW_LINE DEDENT wrd [ i ] = s NEW_LINE DEDENT return res NEW_LINE DEDENT