Back to SDS/2 Parametric Scripts

 

### indexList.py

## Copyright (c) 2006 Bruce Vaughan, BV Detailing & Design, Inc.

## All rights reserved.

###############################################################

"""

Return an index list of all occurrances of 'item' in string 's'.

Optional start search position 'i'

"""

def indexList(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