Skip to content

Commit 02a373f

Browse files
Add functions for removing duplicates and counting items
1 parent 8cfff6e commit 02a373f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def remove_duplicates(seq: list) -> list:
2+
result = []
3+
for item in seq:
4+
if item not in result:
5+
result.append(item)
6+
return result
7+
8+
def list_counts(seq: list) -> dict:
9+
counts = {}
10+
for item in seq:
11+
counts[item] = counts.get(item, 0) + 1
12+
return counts
13+
14+
def reverse_dict(d: dict) -> dict:
15+
return {v: k for k, v in d.items()}

0 commit comments

Comments
 (0)