The Hostile Takeover
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
Given two dicts base and override, recursively merge: if a key exists in both AND both values are dicts, recurse. Otherwise override's value replaces base's value. Keys only in base are kept; keys only in override are added. Do not mutate inputs.
Summary
One dict eats another.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.