Merge two dict in separate list by id I have following data structure

&gt;&gt;&gt; a = [{'id': 1, 'name': 'a'}, {'id': 2, 'name': 'b'}]
&gt;&gt;&gt; b = [{'id': 1, 'age': 12}, {'id': 2, 'age': 21}]


I want to merge the dictionaries present in list b with list a by matching id. (a and b have the same number of entries, but the order can be different.)
So I want following: 

[{'age': 12, 'id': 1, 'name': 'a'}, {'age': 21, 'id': 2, 'name': 'b'}]


I am doing it by following: 

&gt;&gt;&gt; for ta in a: 
...   for tb in b:
...     if ta['id'] == tb['id']:
...       ta.update(tb)
... 
&gt;&gt;&gt; a
[{'age': 12, 'id': 1, 'name': 'a'}, {'age': 21, 'id': 2, 'name': 'b'}]
&gt;&gt;&gt; 


Is there a better Pythonic way of doing it?
You are saying 


  I want to merge the dictionary present


but what makes your task a bit difficult is that you are not handling dictonnaries but lists. Among other things, if you keep that idea that way, you'll have to iterate over n*m pairs (ta, tb) (where n and m are respective size of a and b).

A probably better idea would be to reorganise data in a and b to have them as an actual dict mapping id to some additional information. Then, merging will go through maximum n + m elements.