I'm trying to complete problem set 4 and the find_best_shifts_rec function. It works for the most part, but for some reason, it is unable to completely decode the fable. One of the recursive calls fails at the same spot in the fable. Any help would be appreciated
Here is my code:
def find_best_shifts_rec(wordlist, text, start):
for shift in range(27):
s = text[:start] + apply_shift(text[start:], shift)
space = s.find(" ", start)
if space > 0 and is_word(wordlist, s[start:space]):
return [(start, shift)] + find_best_shifts_rec(wordlist, s, space + 1)
if space < 0 and is_word(wordlist, s[start:]):
return [(start, shift)]
if space < 0 and not is_word(wordlist, s[start:]):
continue

Hey! We 've verified this expert answer for you, click below to unlock the details :)

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

Looking for something else?

Not the answer you are looking for? Search for more explanations.

## More answers

Looking for something else?

Not the answer you are looking for? Search for more explanations.