Oct-10-2019, 03:28 PM
By unpacking each dictionary in that manner, you're essentially doing this:
If you reverse the order of x and y, you'll get the opposite result:
{'a': 1, 'b': 2, 'b': 3, 'c': 4}In that case, the interpreter is going to:
- Initialize the dict
- Set key "b" to 2
- Reset key "b" to 3
If you reverse the order of x and y, you'll get the opposite result:
x = {'a': 1, 'b': 2} y = {'b': 3, 'c': 4} z = {**y, **x} print(z)
Output:{'b': 2, 'c': 4, 'a': 1}