← All Exercises

Python Dictionary Operations

basicpython~10min

Background

Dictionaries are Python primary mapping structure, used extensively in data processing, configuration, and JSON handling.

Problem

Write a function that takes two dictionaries and returns a merged dictionary where values from the second override the first for common keys.

Input

Two dictionaries with string keys and any values.

Output

A merged dictionary with values from the second dict overriding the first.

Sample tests

Sample 1

Input: {"a":1, "b":2}, {"b":3, "c":4}
Expected: {"a":1, "b":3, "c":4}

Your solution

Learning objective

Learn dictionary merging with unpacking syntax and understand override behavior.