I wanted to sum 2 dictonaries
inv = {'gold coin': 41, 'rope': 1}
inv2 = {'rope': 3, 'torch': 10}
I achieved it with Counter subclass
inv = Counter({'gold coin': 41, 'rope': 1})
inv2 = Counter({'rope': 3, 'torch':10})
result = dict(inv + inv2)
print(result)
With output:
{'gold coin': 41, 'rope': 4, 'torch': 10}
And now i'm curious if it's possible to sum those 2 dictionaries with loop and other ways.
Any ideas ?