Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

# add keys to existing dictionary

# add keys to existing dictionary
#To update multiple keys use update
southbay = {'cupertino': 10, 'fremont': 10, 'sanjose': 7, 'sunnyvale': 6}
northbay = {'vallejo':6 , 'sonoma': 3, 'napa': 2, 'vacaville': 4}
southbay.update(northbay)

# to add a single value
southbay = {'cupertino': 10, 'fremont': 10, 'sanjose': 7, 'sunnyvale': 6}
southbay['santaclara'] = 8

 
PREVIOUS NEXT
Tagged: #add #keys #existing #dictionary
ADD COMMENT
Topic
Name
6+2 =