I think what you're missing in your solution is the use of the keys-method and the get-method that comes with dictionaries. The keys-method will return a list of all of keys in the key-value pairs from your dictionary. Whereas, the get-method will return the value associated with a key in the dictionary, if it's there, or return a default (defaults to None).
To do what you're trying to do, I'd recommend something like this:
x = {'a': 1, 'b': 1, 'c': 1} # dictionary x
y = {'c': 1, 'd': 1, 'e': 1} # dictionary y
z = dict([
(key, x.get(key, 0) + y.get(key, 0)) # key, sum(x,y)
for key in # for every key in
set(x.keys() + y.keys()) # the unique set of keys from x + y
])
Step #1: set(x.keys() + y.keys()) - add the two lists of keys together and removes the duplicates (by making it a set)
Step #2: for key in - loop over every key in the set from Step #1
Step #3: x.get(key, 0) + y.get(key, 0) - sum the values associated with that key from each of the dictionaries; using 0 as a default if there is no associated value
Step #4: (key, ...) - create a key, value pair using the new sum and the original key
Step #5: dict([...]) - create a new dictionary from the list of key-value pairs
Does that make sense? I hope that helps!