Good afternoon,
I need to compare 2 lists and when a certain value in the 'name' field of list 1 does not exist in the 'name' field of list 2 perform some function.
The way I did is comparing index by index and executing if every time the fields are different, but in case I want to execute only when there is no value in any index of list 2
dados1 = [{'name': 'Polo Pedreira', 'id': '02'},
{'name': 'Polo Itu', 'id': '01'}]
dados2 = [{'name': 'Polo Jaguariuna', 'id': '03'},
{'name': 'Polo Itu', 'id': '04'}]
for dadost1 in dados1:
for dadost2 in dados2:
if dadost1['name'] != dadost2['name']:
print(dadost2)
It's returning this to me:
{'name': 'Polo Jaguariuna', 'id': '03'} {'name': 'Polo Itu', 'id': '04'} {'name': 'Polo Jaguariuna', 'id': '03'}
Thank you in advance