def find_words_position(s): start = 0 for word in str.split(s): start = str.find(s, word, start) yield word, start, start + len(word) print(tuple(find_words_position("one two three"))) print(tuple(find_words_position("one one one")))
Standard input is empty