[Fixed]-Display Loop from Database correctly Python


You can use the count function.

if conf.count(a) > 1:
    print a, "-conflict"

The above method is similar to what you have tried. But this is inefficient when the list is large. So, use collections.Counter.

from collections import Counter
occurences = Counter(conf)
for a in list:
    if occurences[a] > 1:
        print a, "- conflict"
        print a

Leave a comment