dupes
is a list of duplicate items found in a list.
clipb
is the original list.
I now search for a part string of dupes
in clipb
.
The aim at the end of the day is to append the word "duplicate"
to the original list per duplicate item found.
dupes = ['0138', '0243']
clipb = ['ABC2b_0243D_K6_LOPA-PAST', 'ABC2b_0016G_M1_LOPA-PABR', 'ABC2b_0138H_M1_LOBR-BRMU', 'ABC2b_0138G_J1_LOPA-PAST', 'ABC2b_0243A_O§_STMA-MACV']
def Filter(clipb, dupes):
return [str for str in clipb if
any(sub in str for sub in dupes)]
#index = clipb.index(clipb) <<--- no idea how to add it in here
rs_found = (Filter(clipb, dupes))
print ("found dupicates from the original list are: ","\n", rs_found)
Current output is only the list of duplicates found. Found duplicates from the original list are:
['ABC2b_0243D_K6_LOPA-PAST', 'ABC2b_0138H_M1_LOBR-BRMU', 'ABC2b_0138G_J1_LOPA-PAST', 'ABC2b_0243A_O§_STMA-MACV']
My problem is that I have no idea how to format the Filter
to include outputting the index of found duplicates so I can actually change the items.