Skip to content

Commit 6595927

Browse files
authored
Merge pull request #73 from FurkanBaytak/patch-3
Create sequences_furkan_baytak.py
2 parents 7d99bb1 + b8493b5 commit 6595927

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Week02/sequences_furkan_baytak.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Creating a list, tuple, set and dictionary
2+
my_list = [1, 2, 3, 4, 5]
3+
my_tuple = (1, 2, 3, 4, 5)
4+
my_set = {1, 2, 3, 4, 5}
5+
my_dict = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five'}
6+
7+
8+
# Remove duplicate items from a list
9+
def remove_duplicates(list_):
10+
return list(set(list_))
11+
12+
13+
# Count the occurence of each item in a list and return as a dictionary
14+
def list_counts(list_):
15+
return {i: list_.count(i) for i in list_}
16+
17+
18+
# Reverse a dictionary, switch values and keys with each other
19+
def reverse_dict(dict_):
20+
return {v: k for k, v in dict_.items()}

0 commit comments

Comments
 (0)