Suppose I have the following list:
my_list = ["sam","sam", "is", "a", "is", "sam" , "good", "person", "person"]
Now my requirement is to write a function that selectively removes duplicates. I want to use this function in a for loop.
suppose I want to remove "sam" duplicates
Which means after 1st iteration my desired result is as follows:
my_list = ["sam", "is", "a", "is", "good", "person", "person"]
only duplicates of "sam" are removed.
similarly, after the second iteration, I want to remove is "person", so my list will look like:
my_list = ["sam", "is", "a", "is", "good", "person"]
Please suggest a way I can do this?
Thanks & Regards