-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDictionary_P13.py
More file actions
53 lines (37 loc) · 977 Bytes
/
Dictionary_P13.py
File metadata and controls
53 lines (37 loc) · 977 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
48
49
50
51
52
53
print("\n\t\t\tDictionary")
print("\t\t\t----------")
print("1.Create")
print("2.Insert")
print("3.Update")
print("4.Delete")
print("5.Exit")
d={}
while True :
c=int(input("\nEnter the choice :"))
if(c==1):
d={}
n=int(input("Enter the number of elements :"))
for i in range(n):
k=input("Enter the Key: ")
v=input("Enter the Value: ")
d[k]=v
print(d)
elif(c==2):
nk=input("Enter the new Key :")
nv=input("Enter the new Value :")
d[nk]=nv
print(d)
elif(c==3):
ok=input("Enter the Key :")
ov=input("Enter the value to update:")
d[ok]=ov
print(d)
elif(c==4):
dk=input("Enter the Key to delete :")
del d[dk]
print(d)
elif(c==5):
print("Exiting....")
break
else:
print("Enter a valid option between 1-5")