Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

Add element of list in dictionary of other list at the same index

$
0
0

I have a list of values, and a list of dictionaries such as:

my_values = ["A", "B", "C"]my_dicts = [{...}, {...}, {...}]

I would like to unpack my values into my dictionaries so that the value in position n goes in the nth dictionary, such as:

my_new_dicts = [{"value": "A", ...}, {"value": "B", ...}, {"value": "C", ...}]

My list/dict comprehension attempts so far yield a new list of n*n dictionaries.


Viewing all articles
Browse latest Browse all 11661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>