Light Mode
Dark Mode
bug maybe?

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?

  • feedback
Created: Feb. 10, 2015, 5:48 p.m.
Updated: Feb. 11, 2015, 6:41 a.m.
0
5
User avatar
or_halimi