We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 71f5b39 commit 3a73008Copy full SHA for 3a73008
Week03/sequences_dilara_agac.py
@@ -0,0 +1,30 @@
1
+def remove_duplicates(seq: list) -> list:
2
+ """
3
+ This function removes duplicates from a list.
4
5
+ result = []
6
+ for item in seq:
7
+ if item not in result:
8
+ result.append(item)
9
+ return result
10
+
11
12
+def list_counts(seq: list) -> dict:
13
14
+ This function counts the number of occurrences
15
+ of each item in a list.
16
17
+ counts = {}
18
19
+ counts[item] = counts.get(item, 0) + 1
20
+ return counts
21
22
23
+def reverse_dict(d: dict) -> dict:
24
25
+ This function reverses the keys and values of a dictionary.
26
27
+ reversed_dict = {}
28
+ for key, value in d.items():
29
+ reversed_dict[value] = key
30
+ return reversed_dict
0 commit comments