I have a dictionary that contains lists. I want to create multiple dictionaries from it.
The original is {'user': ['BEBR', 'FRPA', 'GEMU'], 'udp': ['COLT_BE_8845-udp', 'COLT_FR_8845-udp', 'COLT_DE_8845-udp']}
and I want something like this
[{'user': 'BEBR', 'udp': 'COLT_BE_8845-udp'},
{'user': 'FRPA', 'udp': 'COLT_FR_8845-udp'},
{'user': 'GEMU', 'udp': 'COLT_DE_8845-udp'},
....]
i have a sandbox here
You can do
res = [{'user':user,'udp':udp} for user, udp in zip(*d.values())]
where d is your original dictionary
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With