For those of you that enjoy clever/hacky one-liners.
Here is DL
to LD
:
v = [dict(zip(DL,t)) for t in zip(*DL.values())]
print(v)
and LD
to DL
:
v = {k: [dic[k] for dic in LD] for k in LD[0]}
print(v)
LD
to DL
is a little hackier since you are assuming that the keys are the same in each dict
. Also, please note that I do not condone the use of such code in any kind of real system.