Skip to content

Commit 5a9dfc3

Browse files
authored
Create sequences_emin_badur.py
1 parent eab1397 commit 5a9dfc3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Week03/sequences_emin_badur.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
def remove_duplicates(seq: list) -> list :
2+
#This function remove duplicates from list. But we could use the set method to same purpose too.
3+
current_index = 0
4+
while current_index < len(seq) - 1 :
5+
if seq[current_index] == seq[current_index + 1]:
6+
del seq[current_index + 1]
7+
else :
8+
current_index += 1
9+
return seq
10+
11+
def list_counts(seq: list) -> dict:
12+
return {item: seq.count(item) for item in seq}
13+
14+
def reverse_dict(d: dict) -> dict:
15+
new_dict = {}
16+
for key, value in d.items():
17+
new_dict[value] = key
18+
return new_dict
19+
20+
21+
22+
23+
24+

0 commit comments

Comments
 (0)