Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Short and clear solution in Clear category for The Flat Dictionary by EdinsonUwU
def flatten(dictionary):
def flattenAux(dictionary,key = None,nuevoDict = {},nameKey=""):
try:
for i in dictionary.keys():
nameKey += i + '/'
if (dictionary[i] == {}):
nuevoDict[nameKey[:len(nameKey)-1]] = ""
else:
flattenAux(dictionary[i],i,nuevoDict,nameKey)
nameKey = nameKey[:(len(nameKey)-len(i)-1)]
except:
nuevoDict[nameKey[:len(nameKey)-1]] = dictionary
return nuevoDict
return flattenAux(dictionary)
June 30, 2021