Skip to content

Commit c94b71d

Browse files
authored
Add functions to remove duplicates and count items
1 parent 8415c79 commit c94b71d

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
def remove_duplicates(items):
2+
return list(dict.fromkeys(items))
3+
4+
5+
def list_counts(items):
6+
counts = {}
7+
8+
for item in items:
9+
counts[item] = counts.get(item, 0) + 1
10+
11+
return counts
12+
13+
14+
def reverse_dict(dictionary):
15+
reversed_dict = {}
16+
17+
for key, value in dictionary.items():
18+
reversed_dict[value] = key
19+
20+
return reversed_dict

0 commit comments

Comments
 (0)