Reputation: 135
I have two lists structured like:
list1 = [1,2]
list2 = [{'name':'foo', 'address':'bar'}, {'name':'foo1', 'address':'bar1'}]
I thing is that i want to append the list1 into list2 and create something like:
new_list = [{'name':'foo', 'address':'bar', 'num':'1'}, {'name':'foo1','address':'bar1', 'num':'2'}]
how can this be acheived?
Upvotes: 1
Views: 89
Reputation: 61225
Simple for loop
for i, j in enumerate(list2):
j.update({'num': list1[i]})
Upvotes: 1