Merge Two Dictionaries
Merge two dictionaries into one. If a key exists in both, the second dictionary's value should win.
Input format: each dictionary is given on its own line as comma-separated key:value pairs, e.g. a:1,b:2.
Approach: parse each line into a real dictionary, then merge them with dictionary unpacking {d1, d2} — keys from d2 override matching keys from d1.
Input: Two lines, each a comma-separated list of key:value pairs (values are whole numbers), e.g. a:1,b:2.
Output: One line: the merged dictionary, printed in Python dict format.
a:1,b:2 b:3,c:4
{'a': 1, 'b': 3, 'c': 4}- 1 <= number of pairs per line <= 100
Hint 1
{**d1, **d2} builds a new dictionary containing all of d1's pairs, then all of d2's pairs — matching keys from d2 overwrite d1's.
Hint 2
The parse() helper is already provided to turn each input line into a dictionary.
Once both lines are parsed into real dictionaries, merging them is one line: merged = {d1, d2}. Dictionary unpacking inserts d1's pairs first, then d2's — so on a shared key, d2's value is written last and wins, matching the required "second dictionary wins" rule.