Input Format
The first line contains the string .
The second line contains the string .
Constraints

Output Format
Print the tuple in this format: (start _indexend _index).
If no match is found, print (-1, -1).

hackerrank re start and end problem solution in python programming

Problem solution in Python 3 programming language.

import re
S = input()
k = input()
anymatch = 'No'
for m in re.finditer(r'(?=('+k+'))',S):
    anymatch = 'Yes'
    print((m.start(1),m.end(1)-1))
if anymatch == 'No':
    print((-1, -1))

Problem solution in Python 2 programming language.

import re
S = raw_input()
k = raw_input()
anymatch = 'No'
for m in re.finditer(r'(?=('+k+'))',S):
    anymatch = 'Yes'
    print (m.start(1),m.end(1)-1)
if anymatch == 'No':
    print (-1, -1)