mystring = 'John has a really nice powerbook.' substr = ' ' # space pos = 0 indices = [] while True: i = mystring.find(substr,pos) if i==-1: break indices.append(i) pos = i+1 print indices > [4, 8, 10, 17, 22]
Pierre -- http://mail.python.org/mailman/listinfo/python-list