Identify duplicate values in a list in Python

前端 未结 12 1922
渐次进展
渐次进展 2020-11-29 06:31

Is it possible to get which values are duplicates in a list using python?

I have a list of items:

    mylist = [20, 30, 25, 20]

I k

12条回答
  •  鱼传尺愫
    2020-11-29 06:46

    The following list comprehension will yield the duplicate values:

    [x for x in mylist if mylist.count(x) >= 2]
    

提交回复
热议问题