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 188 views
2 answers 131 views
2 answers 163 views
1 answer 149 views
2 answers 176 views
1 answer 135 views
...