Q:

Select unique names within a list removing duplicate entries

Is there a way I can highlight only the lines in a file that are not duplicated?
Taking as example the following file content:
Product 1
Product 1
Product 2
Product 3
Product 3

I want to be able to highlight Product 2, as its the only one without a duplicate.

A:

You could do something like this:
from collections import Counter
with open("filename.txt", "r") as f:
    count = Counter(f.read().split("\n"))
    print [x for x in count if count[x] == 1]

This will maintain a counter of all lines, with how many times each line occurs, from which you can filter out the ones you need later.

