In this HackerRank Re.start() & Re.end() problem solution You are given a string S. Your task is to find the indices of the start and end of string k in S.

HackerRank Re.start() & Re.end() in python problem solution

HackerRank Re.start() & Re.end() in python problem solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
import re
s=raw_input()
k=raw_input()
a=[]
s1=""
s2=""
c=0
for i in range(0,(len(s)-len(k))):
    s1=""
    a=[]
    for j in range(i,i+len(k)):
        s1=s1+s[j]
    a.append(i)
    a.append(i+len(k)-1)
    if s1==k:
        c=c+1
        s2= ', '.join(map(str,a))
        print "("+s2+")"
if c==0:
   print "(-1, -1)"