Say i have two lists of dictionaries:
a=[{'name':'A','color':'1'},
{'name':'B','color':'2'}]
b=[{'name':'A','color':'3'},
{'name':'c','color':'1'}]
I need something like this:
for i in a:
if i['name'] is not existent in b['name']:
do this.
else:
if i['color'] is < than the corresponding item in b list:
do that.
I don't know how to fetch the element form the second list which causes the iteration to go on "else:".
I need to say that the first list is smaller(several hundred items) but the second one has several thousand dictionaries, each with about a hundred items- efficiency is very important.
I did think about making a list of all values for the key['name'] in both lists and compare that but it would mean iterating first time to make these lists and then reiterating over the lists in order to do this or do that. Thanks in advance!