Skip to content

Commit ef7cca9

Browse files
authored
Add utility functions for list and dictionary operations
1 parent f083b29 commit ef7cca9

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎Week03/sequence_ugur_kurt.py‎

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

0 commit comments

Comments
 (0)