-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionary.py
More file actions
47 lines (33 loc) · 875 Bytes
/
dictionary.py
File metadata and controls
47 lines (33 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Isha Bule UCE2021610
# Use of dictionary
myDict = {"Chase": "Pursuit", "Legacy": "Heritage", "Bizarre": "Uncanny"}
def addWord(key, value):
myDict[key] = value
def sortDict():
for i in sorted(myDict):
print((i, myDict[i]), end=" ")
def search(key):
print(key, ":", myDict[key])
def remove(key):
del myDict[key]
def sameMeaning():
for i in sorted(myDict):
temp = myDict[i]
print(i, end=":")
for j in sorted(myDict):
if (temp == myDict[j]):
print(myDict[j])
addWord("house", "home")
remove("Legacy")
search("Chase")
sameMeaning()
sortDict();
# ***********OUTPUT**********
'''
Chase : Pursuit
Bizarre:Uncanny
Chase:Pursuit
house:home
('Bizarre', 'Uncanny') ('Chase', 'Pursuit') ('house', 'home')
Process finished with exit code 0
'''