-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path2.AddingRemovingElement.py
More file actions
46 lines (30 loc) · 1.22 KB
/
2.AddingRemovingElement.py
File metadata and controls
46 lines (30 loc) · 1.22 KB
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
##------------------------------------------------------------------------------------------------------
#Created By:Ravishankar Chavare
#version:python 3.7
#Date:15/03/2019
#File_des:Adding And Removing element from Dictionary
##------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------
# Adding Another key and Value TO Dictionary
#-------------------------------------------------------------------
simpledict={'name':'jhon','roll':12}
#add age =10 in simpledict
simpledict['age']=10
print(simpledict)
#adding imageurl=''
simpledict['imageurl']=''
print(simpledict)
#-------------------------------------------------------------------
# Removing Value From Dictionary
#-------------------------------------------------------------------
#use pop method to remove items from dict
simpledict.pop('roll')
print(simpledict)
#-------------------------------------------------------------------
# Deleting And Clearing Dictionary
#-------------------------------------------------------------------
#For Clearing the Dict (empty)
simpledict.clear()
print(simpledict)
#use del keyword to delete Dictionary
del simpledict