1# Basic syntax:
2dict_of_counts = {item:your_list.count(item) for item in your_list}
3
4# Example usage:
5your_list = ["a", "b", "a", "c", "c", "a", "c"]
6dict_of_counts = {item:your_list.count(item) for item in your_list}
7print(dict_of_counts)
8--> {'a': 3, 'b': 1, 'c': 3}
1some_list=['a','b','c','b','d','m','n','n']
2
3 my_list=sorted(some_list)
4
5duplicates=[]
6for i in my_list:
7 if my_list.count(i)>1:
8 if i not in duplicates:
9 duplicates.append(i)
10
11print(duplicates)
1a = [1,2,3,2,1,5,6,5,5,5]
2
3import collections
4print([item for item, count in collections.Counter(a).items() if count > 1])
5
6## [1, 2, 5]
1>>> your_list = ['one', 'two', 'one']
2>>> len(your_list) != len(set(your_list))
3True
1a = [1,2,3,2,1,5,6,5,5,5]
2
3import collections
4print([item for item, count in collections.Counter(a).items() if count > 1])
5
6## [1, 2, 5]
7
1def checkDuplicate(user):
2 if len(set(user)) < len(user):
3 return True
4 return False