-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program-24.py
32 lines (30 loc) · 913 Bytes
/
Program-24.py
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
# Python Journal Program - Unit-1
# Definition : WAP TO CREATE DICTION DYNAMICALLY AND PERFORM UPDATE DEL AND ADD ACTION.
dict1 = {}
b = int(input("Total number of elements = "))
for i in range(1, b + 1):
dict1[input("Enter Key for above element = ")] = input("Enter Element for key = ")
print(dict1)
key = input("Enter key to update = ")
value = input("Enter new value = ")
dict1.update({key: value})
dict1.pop(input("Enter Key to delete = "))
print(dict1)
dict1[input("Enter key for new value = ")] = input("Enter new value = ")
print(dict1)
"""
Output :
Total number of elements = 2
Enter Element for key = 1
Enter Key for above element = 1
Enter Element for key = 2
Enter Key for above element = 2
{'1': '1', '2': '2'}
Enter key to update = 1
Enter new value = 3
Enter Key to delete = 1
{'2': '2'}
Enter new value = 1
Enter key for new value = 1
{'2': '2', '1': '1'}
"""