|
Post by dejohnny on May 16, 2012 10:39:20 GMT -5
I have defined a procedure find_last, that takes as input two strings, a search string and a target string, that should return the last position in the search string where the target string is found. If the string is not found the procedure should return -1. Is there a way to fix this? Python code: def find_last(searched, target): first_pos = searched.find(target) size = len(searched) print size last_pos =1 while last_pos <= size: #first_pos = searched.find(target) start_char = searched.find(target, first_pos) last_pos = searched.find(target, start_char + 1) last_pos += last_pos print last_pos return last_pos
print find_last('aaaa','a')
|
|