Input
base = {"a": 1, "b": {"x": 1, "y": 2}}
override = {"b": {"y": 99, "z": 3}}Output
{"a": 1, "b": {"x": 1, "y": 99, "z": 3}}Implement `merge_config(base, override)` that deep-merges two Python dicts and returns a new dict. Keys present in only one dict are kept as-is. If both values are dicts, merge recursively. Otherwise the override value...
main.pyEditable starterbase = {"a": 1, "b": {"x": 1, "y": 2}}
override = {"b": {"y": 99, "z": 3}}{"a": 1, "b": {"x": 1, "y": 99, "z": 3}}base = {"a": 1, "b": {"x": 1}, "c": 3}
override = {"b": None, "c": {"k": 1}}{"a": 1, "c": {"k": 1}}None deletes the key; a non-dict override replaces the base dict.
How would you detect and reject cyclic references in input objects?