How to add items to dictionary in Python

1 Answer

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

dic.update({"c++": 222, "swift": 777});
 
print(dic)     


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

 



answered Oct 22, 2020 by avibootz

Related questions

1 answer 159 views
1 answer 158 views
158 views asked Oct 22, 2020 by avibootz
1 answer 173 views
1 answer 186 views
1 answer 173 views
...