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)
1l=[1,2,3,4,5,2,3,4,7,9,5]
2l1=[]
3for i in l:
4 if i not in l1:
5 l1.append(i)
6 else:
7 print(i,end=' ')
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 Find_Repeated(x):
2 x2=sorted(x)
3 List_Of_Repeated=[]
4 for i in x2:
5 if x2.count(i)>1:
6 List_Of_Repeated.append([i,x2.count(i)])
7 for c in range(x2.count(i)):
8 for j in x2:
9 if i==j and x2.count(i)>1:
10 x2.remove(i)
11 List_Of_Repeated.sort()
12 return List_Of_Repeated
13
14List=[1,2,3,4,4,4,5,5,5,5,5,1,1,2,2,3,7,8,6]
15
16# Repeated numbers: [1,2,3,4,5]
17
18# Simple print output:
19
20print(Find_Repeated(List),"\n")
21
22# For a neat output:
23
24print("[ Value , Times Repeated ] \n")
25print("For example: [2,4] The value 2 was repeated 4 times. \n")
26for i in Find_Repeated(List):
27 print(i)
28