In python, how do I check if an objects occurs more than 2 times. So basically
test = [object1,object2,object1,object1]
#some stuff
test = [object1]
or
test =[object1,object2,object1,object2,object1,object2]
#some stuff
test =[object1,object2]
In python, how do I check if an objects occurs more than 2 times. So basically
test = [object1,object2,object1,object1]
#some stuff
test = [object1]
or
test =[object1,object2,object1,object2,object1,object2]
#some stuff
test =[object1,object2]
a = ['a', 'b', 'c', 'a', 'a']
list(set([x for x in a if a.count(x) > 2]))
This returns
['a']
If you need unique values, wrap it in a set.