Contact: aviboots(AT)netvision.net.il
39,939 questions
51,876 answers
573 users
s = 'python php python java python c++ python c' substr = "python" indexes = [i for i in range(0, len(s)) if s[i:].startswith(substr)] print(indexes) ''' run: [0, 11, 23, 34] '''
import re; s = 'python php python java python c++ python c' substr = "python" matches = re.finditer(substr, s) indexes = [match.start() for match in matches] print(indexes) ''' run: [0, 11, 23, 34] '''