Skip to content

Commit 64b7e8e

Browse files
authored
Added count duplicates in a list
1 parent a140f52 commit 64b7e8e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# count duplicates in a list
2+
my_list = [1, 2, 1, 1, 1, 2, 3, 5, 4]
3+
duplicates = []
4+
for values in my_list:
5+
if my_list.count(values) > 1:
6+
duplicates.append(values)
7+
8+
print(len(duplicates)) # here len function is used to count the duplicates

0 commit comments

Comments
 (0)