Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
recursion solution in Clear category for The Flat Dictionary by Olpag
def flatten(dictionary, p=''):
flat = {}
for k,v in dictionary.items():
key = p + k
if isinstance(v, dict) and v:
flat.update(flatten(v, key + '/'))
else:
flat[key] = '' if v == {} else v
return flat
Aug. 29, 2019
Comments: