Light Mode
Dark Mode
"Does not accept solution", why? My code below

def flatten(dictionary): stack = [((), dictionary)] result = {} while stack: path, current = stack.pop() for k, v in current.items(): if v == {}: v = '' if isinstance(v, dict): stack.append((path + (k,), v)) else: result["/".join((path + (k,)))] = v return result

Created: March 22, 2015, 7:03 a.m.
Updated: April 14, 2015, 8:16 p.m.
0
6
User avatar
spencerpomme