Answer the question
In order to leave comments, you need to log in
How to make one from two arrays?
Hello!
There are two arrays:
First
Answer the question
In order to leave comments, you need to log in
companiesDict = { n['id']: { k: n[k] for k in ('name', 'disabled') } for n in arr1 }
arr3 = [ { **n, **companiesDict.get(n['company'], {}) } for n in arr2 ]
Given the sorted second list and the uselessness of id
for item in list1:
index = item.pop('id')
list2[index].update(item)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question