I would like to give some feedback about ...
From: http://www.checkio.org/mission/flatten-dict/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.93 Safari/537.36
When I try to run this code on python 3 I got syntax error
def flatten(dic, prefix ="")
results = {}
for k in dic.keys():
if isinstance(dic[k], dict):
results = dict(list(results.items()) + list(flatten(dic[k],k).items()))
else:
key = prefix+"/"+k if prefix else k
results[key] = dic[k]
return results
Its working on my machine, am i not allow to add "prefix" to the function?
Created at: 2015/02/10 17:48; Updated at: 2015/02/11 06:41