Counter
- полезная утилита для подсчета количества раз, когда конкретный элемент появляется в итерации:
>>> dups
[[19, 31, 3, 20, 33, 10], [36, 1, 5, 13, 7, 21], [3, 5, 7, 10, 19, 24], [20, 24, 35, 33, 13, 14], [36, 3, 10, 7, 21, 30], [9, 20, 12, 2, 10, 17], [25, 36, 3, 34, 9, 23], [8, 14, 5, 35, 22, 2], [31, 11, 7, 14, 18, 3], [4, 14, 16, 13, 27, 9]]
>>> from collections import Counter
>>> dupe_counter = Counter((n for a in dups for n in a))
>>> {num: count for num, count in dupe_counter.items() if count > 1}
{19: 2, 31: 2, 3: 5, 20: 3, 33: 2, 10: 4, 36: 3, 5: 3, 13: 3, 7: 4, 21: 2, 24: 2, 35: 2, 14: 4, 9: 3, 2: 2}