Thursday, June 4

How to Add two Dictionaries in Python

You need to first create the two dictionaries 

>>> d1 = {'a':1,'b':2,'c':3} # dictionary 1
>>> d2 = {'d':4,'e':5,'f':6} # dictionary 2

for add two dictionaries you have to use the Exponent operator like below 
          >>> d3 = { **d1, **d2 }


No comments:

Post a Comment

thank Q

Are you looking for ......