The objective is to update new key-value in a list of dict, whereby the value is from another nested list.
This can be realised via
ls1=[[1,23],[2,34,5]]
ls2=[dict(t=1),dict(t=1)]
all_data=[]
for x,y in zip(ls1,ls2):
y['new']=x
all_data.append(y)
For compactness, I would like to have the for-loop in the form of list comprehension.
all_data=[y.update({'new':x}) for x,y in zip(ls1,ls2)]
But, by doing so, I got a list of None instead. May I know how to resolve this?