2020-08-14

Python - List detect duplicates that occur only "n" or more times

l = [1,2,3,4,4,5,5,6,1,1,1,1]

n = 3

print(list(set([x for x in l if l.count(x) >= n])))


No comments:

Post a Comment