looking for some solutions? You are welcome.

SOLVED: merge two dictionaries with same key values

Rahul Sharma:

I have two dictionaries which consist same keys

a = {'a':[3,2,5],

b = {'b':[7,4],

When i merge them the keys of dictionary b replaces the keys of a because of the same name. Here's the merge code I am using

z = dict(list(a.items()) + list(b.items()))

Is there somehow I can keep all the keys, I know dictionaries can't have same key name but I can work with something like this:

a = {'a':[3,2,5],

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots

No comments: