Skip to content

Commit 87f2032

Browse files
authored
Create sequences_muhammet_berk_can.py
1 parent d44760a commit 87f2032

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
my_list = ["Raw Prime Meat", True , 211, "Saddle"]
3+
my_tuple = "Rex","Pterenadon",215,False,("Raptor","Microraptor")
4+
my_dictionary = {"Narcotic" :" a tranquilizer", "duration_in_minute":10,}
5+
my_set = set(["42",64,"sdad","sad",64,42]) #duplicated values will be removed
6+
7+
8+
def remove_duplicates(my_list_):
9+
#We shouldn't use sets for this method, because sets are unordered and if we use
10+
# sets, our list will no longer be ordered, it will be random ordered.
11+
non_duplicated_list = []
12+
for item in my_list_:
13+
if item not in non_duplicated_list:
14+
non_duplicated_list.append(item)
15+
16+
return non_duplicated_list
17+
18+
19+
def list_counts(my_list_):
20+
count_dictionary= {}
21+
22+
for item in my_list_:
23+
if item not in count_dictionary:
24+
count_dictionary[item] = 1
25+
else:
26+
count_dictionary[item] += 1
27+
28+
return count_dictionary
29+
30+
def reverse_dict(dict):
31+
#!!! If there are identical keys in dictionary, when they reversed, if they are integer
32+
# the result will be sum of those integer but if they are string, then
33+
# the result will be the last selected item.
34+
reversed_dict = {}
35+
36+
for item in dict:
37+
reversed_dict[dict[item]] = item
38+
39+
return reversed_dict
40+

0 commit comments

Comments
 (0)