Skip to content

Commit c088870

Browse files
authored
Add functions for list and dict operations
1 parent b34a288 commit c088870

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def remove_duplicates(seq: list) -> list:
2+
"""
3+
This function removes duplicates from a list.
4+
"""
5+
return list(set(seq))
6+
7+
def list_counts(seq: list) -> dict:
8+
"""
9+
This function counts the number of occurrences of each item in a list.
10+
"""
11+
return {i: seq.count(i) for i in seq}
12+
13+
def reverse_dict(d: dict) -> dict:
14+
"""
15+
This function reverses the keys and values of a dictionary.
16+
"""
17+
return {v: k for k, v in d.items()}

0 commit comments

Comments
 (0)