#練習寫寫看
def indices(text, string):
result = []
ind = text.find(string)
nextfind = ind + 1
while nextfind:
result.append(ind)
text = text[nextfind:]
nextfind = text.find(string) + 1
ind += nextfind
return tuple(result)
def find_seq(main, sub):
main_str = ', ' + str(main)[1:-1]
sub_str = ', ' + str(sub)[1:-1]
return tuple(map(indices(main_str, ',').index, indices(main_str, sub_str)))
'''
>>> L = [1, 3, 4, 1, 2, 5, 6, 1, 2, 7, 4, 8, 1, 1, 2]
>>> subL = [1, 2]
>>> find_seq(L, subL)
(3, 7, 13)
'''