# returns an index list

s = [1,2,3,4,1,2,3,4,1,2,4,3,4,5,6,6,7,8,9,1,2,3,4,5,6,7,3,2,1]

 

def get_index(s, item, i=0):

    i_list = []

    while True:

        try:

            i = s.index(item, i)

            i_list.append(i)

            i += 1

        except:

            break

    return i_list

 

       

print get_index(s, 1)

print get_index(s, 4)

print get_index(s, 7)

print get_index(s, 0)

 

"""

>>> [0, 4, 8, 19, 28]

[3, 7, 10, 12, 22]

[16, 25]

[]

"""