import re
s = 'xyxxxyyyxy'
word = 'xy'
for match in re.finditer(word, s):
st = match.start()
en = match.end()
print('Found from index {} to index {}'.format(st, en))
'''
run:
Found from index 0 to index 2
Found from index 4 to index 6
Found from index 8 to index 10
'''