How to append multiple key value pair to a dictionary in Python

1 Answer

0 votes
dic = {'python':34, 'java':12, 'c':19, 'c++':18}
  
dic.update([('c#', 35) , ('php', 982) , ('vb', 92)])

print(dic)
  
  
  
'''
run:
  
{'python': 34, 'java': 12, 'c': 19, 'c++': 18, 'c#': 35, 'php': 982, 'vb': 92}
  
'''

 



answered Jan 29, 2020 by avibootz

Related questions

2 answers 379 views
2 answers 316 views
2 answers 384 views
1 answer 293 views
2 answers 378 views
1 answer 266 views
...