import re
st=input() #The input string
ss=input() #The substring to be searched
lss=len(ss)
lst=len(st)
x=lst-lss
for i in range(x):
r=re.search(r'(%s)'%ss,st,i)
if r:
print(r.start(),r.end())
Above is code is response to a task. The task is:
A string S is given.
I need to find the indices of the start and end of string k in S.
If the input is:
aaadaa
aa
Output should be:
(0, 1)
(1, 2)
(4, 5)
I know the code which i have written is wrong because i am not getting the desired output.I went through and through again the line after for loop. I am not able to convince myself that it is wrong.I just want to know why the code after the for loop does not work? Can someone help me through?