python - Manipulating deep values of a dictionary -
i go from
first = {'a' : {'b' : {'c' : ['d', 'e'], 'f' : ['g'] } } }
to
z = 0 second = {'a' : {'b' : {'c' : {'d' : z, 'e' : z }, 'f' : {'g' : z} } } }
i'm looking pythonic way this. want change every 3rd level elements of first (c , f) list dictionary keys elements of list (d, e example).
>>> {k1: {k2: {k3: {k4:0 k4 in v3} k3, v3 in v2.items()} k2, v2 in v1.items()} k1, v1 in first.items()} {'a': {'b': {'c': {'e': 0, 'd': 0}, 'f': {'g': 0}}}}
=)
(if don't want shot in code review, stick advice 9000 in comments, please. i.e. third level dicts , manipulate directly.)
Comments
Post a Comment