Skip to content

Commit 642072c

Browse files
authored
Create sequences_mert_can_fidan.py
## My Changes Firstly, I created four values and after that I created three functions named as remove_duplicates, list_counts and reverse_dict. ## Checklist - [x] I have read [CONTRIBUTING]. - [x] I have performed a self-review of my own code. - [x] I have run the code locally and it works as explained. - [x] I have commented my code, particularly in hard-to-understand areas
1 parent c2318ad commit 642072c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Week02/sequences_mert_can_fidan.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
my_list = ["Mert", "Can", "Fidan", "Can", "Fidan",24,24,24]
2+
my_tuple = ("Mert", "Can", "Fidan")
3+
my_set = {"Mert", "Can", "Fidan"}
4+
my_dictionary = {
5+
"name": "Mert Can Fidan",
6+
"age": 24,
7+
"alive": True
8+
}
9+
10+
def remove_duplicates (any_list):
11+
return list(set(any_list))
12+
13+
# Simply creates an empty dictionary and copy of given list without duplicates of items.
14+
# After that checks item counts one byu one and adds to newly created dictionary.
15+
def list_counts (any_list):
16+
empty_dict = {}
17+
for i in set(any_list): empty_dict[i] = any_list.count(i)
18+
return empty_dict
19+
20+
# Creates empty dictionary and switch rows in dictionary one by one with foor loop.
21+
def reverse_dict (any_dict):
22+
empty_dict = {}
23+
for key,value in any_dict.items(): empty_dict[value] = key
24+
return empty_dict

0 commit comments

Comments
 (0)