How to update dictionary items in Python

1 Answer

0 votes
dic = {'python': 1, 'java': 98, 'php': 3, 'c#': 4, "swift": 5} 
   
print(dic) 

dic.update({"python": 222, "php": 777});
 
print(dic)     


     
     
'''
run:
 
{'python': 1, 'java': 98, 'php': 3, 'c#': 4, 'swift': 5}
{'python': 222, 'java': 98, 'php': 777, 'c#': 4, 'swift': 5}
 
'''

 



answered Oct 22, 2020 by avibootz

Related questions

...