python-small-examples/md/127.md at master · data-python/python-small-examples

Skip to content

Navigation Menu

Sign in

Appearance settings

Latest commit

File metadata and controls

19 lines (13 loc) · 292 Bytes

@author jackzhenguo
@desc 
@date 2019/11/30

127 找出所有重复元素

from collections import Counter


def find_all_duplicates(lst):
    c = Counter(lst)
    return list(filter(lambda k: c[k] > 1, c))


find_all_duplicates([1, 2, 2, 3, 3, 3])  # [2,3]