You are viewing a single comment's thread. Return to all comments →
text = input("Enter text: ") k = input("Enter k: ") k_len = len(k) r = 0 count = 0
while r + k_len <= len(text): if text[r:r + k_len] == k: print(f'({r}, {r + k_len - 1})') count += 1
r += 1
if count == 0: print(f'(-1, -1)')
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 →
text = input("Enter text: ") k = input("Enter k: ") k_len = len(k) r = 0 count = 0
while r + k_len <= len(text): if text[r:r + k_len] == k: print(f'({r}, {r + k_len - 1})') count += 1
if count == 0: print(f'(-1, -1)')