Skip to content

Commit ee5d65d

Browse files
authored
Add functions for removing duplicates and counting items
1 parent 16e47af commit ee5d65d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎Week03/sequences_sultan_yuksel.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def remove_duplicates(seq: list) -> list:
2+
new_list = []
3+
for i in seq:
4+
if i not in new_list:
5+
new_list.append(i)
6+
return new_list
7+
8+
def list_counts(seq: list) -> dict:
9+
counts = {}
10+
for i in seq:
11+
if i in counts:
12+
count[i] += 1
13+
else:
14+
count[i]
15+
return counts
16+
17+
def reverse_dict(d: dict) ->dict:
18+
new_dict = {}
19+
for key, value in d.items():
20+
new_dict[value] = key
21+
return new_dict

0 commit comments

Comments
 (0)