0
Good afternoon,
I need to compare 2 lists and when a certain value in the 'name' field of the list 1 does not exist in the 'name' field of the list 2 perform some function.
The way I did is comparing index by index and running if every time the fields are different, but in case I want to run only when there is no value in any list 2 Dice
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)
He’s returning it to me:
{'name': 'Polo Jaguariuna', 'id': '03'} {'name': 'Polo Itu', 'id': '04'} {'name': 'Polo Jaguariuna', 'id': '03'}
Thanks in advance
Good evening Alex, I took your thought as a basis and wrote my code again, remaking it as objective as possible.
– Sergio RBJ