-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab1of7.py
More file actions
23 lines (18 loc) · 1.25 KB
/
lab1of7.py
File metadata and controls
23 lines (18 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
verse_dict = {'if': 3, 'you': 6, 'can': 3, 'keep': 1, 'your': 1, 'head': 1, 'when': 2, 'all': 2, 'about': 2, 'are': 1, 'losing': 1, 'theirs': 1, 'and': 3, 'blaming': 1, 'it': 1, 'on': 1, 'trust': 1, 'yourself': 1, 'men': 1, 'doubt': 1, 'but': 1, 'make': 1, 'allowance': 1, 'for': 1, 'their': 1, 'doubting': 1, 'too': 3, 'wait': 1, 'not': 1, 'be': 1, 'tired': 1, 'by': 1, 'waiting': 1, 'or': 2, 'being': 2, 'lied': 1, 'don\'t': 3, 'deal': 1, 'in': 1, 'lies': 1, 'hated': 1, 'give': 1, 'way': 1, 'to': 1, 'hating': 1, 'yet': 1, 'look': 1, 'good': 1, 'nor': 1, 'talk': 1, 'wise': 1}
# print(verse_dict, '\n')
# find number of unique keys in the dictionary
num_keys = verse_dict.keys()
# print(num_keys)
# find whether 'breathe' is a key in the dictionary
contains_breathe = 'breathe' in verse_dict
# print(contains_breathe)
# create and sort a list of the dictionary's keys
sorted_keys = list(verse_dict.keys())
sorted_keys.sort()
# get the first element in the sorted list of keys
# print(sorted_keys)
# find the element with the highest value in the list of keys
highest_key_value = max(verse_dict, key=verse_dict.get)
print(highest_key_value)
bonus_question_what_is_the_first_key_in_verse_dict = list(verse_dict)
# print(bonus_question_what_is_the_first_key_in_verse_dict[0])