So my code is the following:
What i am trying to do is to find some spread letters in a text(search_str) and form a word(target_str) out of them if it exists. How ever i keep on getting "IndexError: string index out of range" for the line:
what am i doing wrong?
Kind regards
def correction(search_str, target_str): i = 0 new_string = '' while True: if search_str.find(target_str[i]) != -1: new_string = new_string + target_str[i] else: break i = i + 1 return new_string
What i am trying to do is to find some spread letters in a text(search_str) and form a word(target_str) out of them if it exists. How ever i keep on getting "IndexError: string index out of range" for the line:
search_str.find(target_str[i]) != -1:
what am i doing wrong?
Kind regards