You are viewing a single comment's thread. Return to all comments →
Python 3 solution using only the exercise material, without any extra knowledge of re package.
import re
S = input() k = input()
i = 0
while i < len(S) - 1:
m = re.search(k, S[i:]) if not m: if i ==0: print((-1, -1)) break elif m: print((m.start()+i, m.end()+i-1)) i += m.end() - 1 if len(k)!=1 else m.end()
Seems like cookies are disabled on this browser, please enable them to open this website
Re.start() & Re.end()
You are viewing a single comment's thread. Return to all comments →
Python 3 solution using only the exercise material, without any extra knowledge of re package.
import re
S = input() k = input()
i = 0
while i < len(S) - 1: