16,395 questions
21,880 answers
573 users
import collections lst = [34, 78, 90, 'python', 'java', 34, 'c++', 34, 'python'] print([item for item, count in collections.Counter(lst).items() if count > 1]) ''' run: [34, 'python'] '''
lst = [34, 78, 90, 'python', 'java', 34, 'c++', 34, 'python'] duplicates = set([item for item in lst if lst.count(item) > 1]) print(duplicates) ''' run: {34, 'python'} '''