I want to iterate over a list and a dict in a dict in parallel and find the same strings. If it found the same strings I want to add a value and key pair to the dicts I was iterating over.
I sadly can't get it to work. I simplified the problem to make the code easier to exchange here.
x = ['a', 'c', 'f', 'h']
y = {'root_name': [
{'value01': 'key01', 'value02': 'a'},
{'value01': 'key02', 'value02': 'b'},
{'value01': 'key03', 'value02': 'c'},
{'value01': 'key04', 'value02': 'd'},
{'value01': 'key05', 'value02': 'e'},
{'value01': 'key06', 'value02': 'f'},
{'value01': 'key07', 'value02': 'g'},
{'value01': 'key08', 'value02': 'h'},
{'value01': 'key09', 'value02': 'i'},
{'value01': 'key10', 'value02': 'j'}
]}
for i, j in zip(x, y['root_name']):
if i == j['value02']:
y['root_name']['key_exists'] = True
Aucun commentaire:
Enregistrer un commentaire