Get a unique list of items that occur more than once in a list

后端 未结 7 1084
深忆病人
深忆病人 2020-12-03 17:51

I have a list of items:

mylist = [\'A\',\'A\',\'B\',\'C\',\'D\',\'E\',\'D\']

I want to return a unique list of items that appear more than

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 18:24

    >>> mylist = ['A','A','B','C','D','E','D']
    >>> set([i for i in mylist if mylist.count(i)>1])
    set(['A', 'D'])
    

提交回复
热议问题