We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents eb605a9 + 269e3b3 commit 5207803Copy full SHA for 5207803
Week03/sequences_aysegul_ezber.py
@@ -0,0 +1,17 @@
1
+def remove_duplicates(seq: list) -> list:
2
+ """
3
+ This function removes duplicates from a list.
4
5
+ return list(dict.fromkeys(seq)) # Using dict.fromkeys to remove duplicates while maintaining order.
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 {item: seq.count(item) for item in set(seq)} # Counts occurrences by iterating over unique items in the list.
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()} # Swaps keys and values to reverse the dictionary.
0 commit comments