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 David_Jones
def flatten(dictionary, path=[]):
if not dictionary:
dictionary = ''
if isinstance(dictionary, dict):
flat_dictionary = {}
for key, value in dictionary.items():
flat_dictionary.update(flatten(value, path+[key]))
return flat_dictionary
return {'/'.join(path): dictionary}
June 24, 2019
Comments: