Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to add a key in python dictionary

dict = {'key1': 'geeks', 'key2': 'for'}
 
# using __setitem__ method
dict.__setitem__('newkey2', 'GEEK')
print(dict)
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #add #key #python #dictionary
ADD COMMENT
Topic
Name
6+9 =