I am trying to remove duplicates from 2 lists. so I wrote this function:
a = ["abc", "def", "ijk", "lmn", "opq", "rst", "xyz"]
b = ["ijk", "lmn", "opq", "rst", "123", "456", ]
for i in b:
if i in a:
print "found " + i
b.remove(i)
print b
But I find that the matching items following a matched item does not get remove.
I get result like this:
found ijk
found opq
['lmn', 'rst', '123', '456']
but i expect result like this:
['123', '456']
How can I fix my function to do what I want?
Thank you.