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

后端 未结 7 1064
深忆病人
深忆病人 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:28

    It can be as simple as ...

    print(list(set([i for i in mylist if mylist.count(i) > 1])))
    

提交回复
热议问题