Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to add a key and a value to a dictionary in python

diction = {'key':'value'}#Adding a dictionary called diction.
print(diction)
diction['newkey']='newvalue'#Adding the newkey key to diction with its value.
print(diction)
#output: {'key':'value','newkey':'newvalue'}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #add #key #dictionary #python
ADD COMMENT
Topic
Name
2+3 =