I have two dicts in Python which I want to merge. Some of the keys exists in both dicts and I would like them to be in a list in the new dict. Like this:
A = {'item1': 'val1', 'item2': 'val2'}
B = {'item2': 'val3', 'item3': 'val4'}
Should result in this:
{'item1': 'val1', 'item2': ['val2', 'val3'], 'item3': 'val4'}
How do I do that?