-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8) Find Duplicate.py
55 lines (39 loc) · 1.13 KB
/
8) Find Duplicate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
some_list = ['a', 'b', 'c', 'b', 'd', 'n', 'n']
duplicates = []
for value in some_list:
if some_list.count(value) > 1:
if value not in duplicates:
duplicates.append(value)
print(duplicates)
some_list = ['a', 'b', 'c', 'b', 'd', 'm', 'n', 'n']
duplicate_list = []
for char in range(len(some_list)):
for i in range(char + 1,len(some_list)):
if some_list[i] == some_list[char] and some_list not in duplicate_list:
duplicate_list.append(some_list[char])
print(duplicate_list)
lista=['a','b','c','b','d','m','n','n']
dummy = []
for i in range(len(lista)):
for j in range(i+1,len(lista)):
if(lista[i]==lista[j]):
dummy.append(lista[i])
print(dummy)
letter_list_1 = ['a','b','c','b','d','m','n','n']
letter_list_2 = []
duplicate_found= []
for i in letter_list_1:
if i not in letter_list_2:
letter_list_2.append(i)
else:
duplicate_found.append(i)
print(duplicate_found)
some_list = ['a','b','c','b','d','m','n','n']
tmp = []
dups = []
for item in some_list:
if item in tmp:
dups.append(item)
else:
tmp.append(item)
print(dups)