Skip to content

Instantly share code, notes, and snippets.

@VimalKumarS
Created October 7, 2016 21:03
Show Gist options
  • Save VimalKumarS/fa0643fe10a1f36dca7db090459ded1c to your computer and use it in GitHub Desktop.
Save VimalKumarS/fa0643fe10a1f36dca7db090459ded1c to your computer and use it in GitHub Desktop.
null created by VimalKumarS - https://repl.it/DrK9/0
def flattenDictionay(result,sep,dicobj):
for key, value in dicobj.items():
keyValue= sep +"."+ key if sep else key
if type(value) is dict:
flattenDictionay(result,keyValue,value)
else:
result[keyValue]=value
return result
print(flattenDictionay({},"",{'a': 1, 'c': {'a': 2, 'b': {'x': 5, 'y' : 10}}, 'd': 4}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment