Different keys
Input
merge_dicts({'a': 1}, {'b': 2})
Output
{'a': 1, 'b': 2}
Both keys are kept; the resulting dictionary has keys 'a' then 'b'.
Full lesson preview
Combine two dictionaries into one, with the second dictionary's values overwriting duplicate keys from the first.
Problem statement
Task
Examples
Input
merge_dicts({'a': 1}, {'b': 2})
Output
{'a': 1, 'b': 2}
Both keys are kept; the resulting dictionary has keys 'a' then 'b'.
Input format
Output format
Constraints
Samples
Input
merge_dicts({'a': 1, 'b': 2}, {'b': 3, 'c': 4})
Output
{'a': 1, 'b': 3, 'c': 4}
Key 'b' is present in both; the value from the second dictionary (3) overwrites the first. Key order is 'a', 'b', 'c'.