alisonken1 wrote: > ========== > def getAllIndex(aString=None, aSub=None): > t=dict() > c=0 > ndx=0 > while True: > try: > ndx=aString.index(aSub, ndx) > t[c]=ndx > ndx += 1 > c += 1 > except ValueError: > break > return t > =========== > > This will return a dictionary of what was found; i.e., > >>>> getAllIndex('abcd 1234 efgh 1234 ijkl', '1234') > {0: 5, 1: 15}
Consecutive integers starting at 0 as keys? Looks like you want a list instead of a dict. Peter -- http://mail.python.org/mailman/listinfo/python-list