def multi_find(source, target, start, end): '''Finds all occurrences of the substring target in the string source, within the range start <= pos < end. Returns a list of values.''' result = [] pos = start while pos < end: next_pos = source.find(target, pos, end) if next_pos == -1: break result.append(next_pos) pos = next_pos + 1 return result