Your question is Flatten Nested Dictionaries. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Patreon integrations may represent creator, membership, and campaign metadata as deeply nested dictionaries. Implement flatten_metadata to traverse every nested dictionary and return a single-level dictionary whose keys contain the full path, joined with ..
Given metadata, a dictionary with string keys and JSON-compatible values, return a dictionary mapping each leaf path to its value. A value is a leaf when it is not a dictionary, including lists, strings, numbers, booleans, and None. Empty dictionaries produce no output. Input keys do not contain ..
The function must not mutate metadata. Output key order is not significant.
.def flatten_metadata(metadata):