>------------------------------------------------------------------------ > > > > >Mohammed Altaj wrote: > > >>Hi All >> >>I am having problem with delete line if its belong to another one , example >> >> > >I think, you mean to remove all lines that are substrings of another >line. > >l = ['0132442\n', '13\n', '24\n'] >l = [e.strip() for e in l] > >i = 0 >while True: > try: > for j in range(len(l)): > if i == j: > continue > if l[j].find(l[i]) >= 0: > # line 'j' is superstring of line 'i' > del l[i] > break > else: # doesn't have superstring > i += 1 > except IndexError: > break > >Basically, I try all n*n combinations, and remove substring lines >"in-place". > >BranoZ > > > > > Thanks , but , this work for an ordered substrings , just like what we had ['0132442\n', '13\n', '24\n'] , I would like to remove all substrings from the list , example
['0134314244133', '132443', '234'] 2nd and 3rd strings are also substrings from the 1st one , so it should be removed Thanks -- http://mail.python.org/mailman/listinfo/python-list