1
I have 2 lists of dictionaries and 1 dictionary , as for example the following :
lista1 = [
{'Idade': '8', 'Especie': 'Gato', 'Nome do Animal': 'Felix'},
{'Idade': '57', 'Especie': 'Tartaruga', 'Nome do Animal': 'Michelangelo'},
{'Idade': '12', 'Especie': 'Cao', 'Nome do Animal': 'Rantanplian'},
{'Idade': '2', 'Especie': 'Peixe', 'Nome do Animal': 'Nemo'},
{'Idade': '45', 'Especie': 'Tartaruga', 'Nome do Animal': 'Leonardo'},
{'Idade': '9', 'Especie': 'Cao', 'Nome do Animal': 'Milo'},
{'Idade': '57', 'Especie': 'Tartaruga', 'Nome do Animal': 'Raphael'},
{'Idade': '4', 'Especie': 'Peixe', 'Nome do Animal': 'Dory'} ]
lista2 = [
{'Nome do Dono ': 'Ana', 'Nome do Animal': 'Michelangelo'},
{'Nome do Dono ': 'Eva', 'Nome do Animal': 'Dory'},
{'Nome do Dono ': 'Ada', 'Nome do Animal': 'Rantanplan'},
{'Nome do Dono ': 'Ana', 'Nome do Animal': 'Leonardo'},
{'Nome do Dono ': 'Eva', 'Nome do Animal': 'Felix'},
{'Nome do Dono ': 'Ana', 'Nome do Animal': 'Raphael'},
{'Nome do Dono ': 'Eva', 'Nome do Animal': 'Nemo'} ]
dicionario3 ={
'Eva': ['Dory', 'Felix', 'Nemo'],
'Ana': ['Michelangelo', 'Leonardo', 'Raphael'],
'Ada': ['Rantanplan']}
And what I want to do is turn dictionary 3 into a list of dictionaries where instead of the names of the animals the average age of those animals per owner will be and round those values up "for example in the case of Eva the value of 4,6 , soon will have to appear 5 instead of 4. I have tried several things and did not get result , someone can help ?
What I want is this :
[{'Ana':'53','Eva':'5','Ada':'12'}]
My first question is how to get only the names of the animals in the dictionary3
I think it would be clearer if you wrote down what is the expected result for the example entry you used. Could you do that? And what things have you tried that haven’t worked? In general it is easier to write a good answer if we know what you have tried and what difficulties you have encountered.
– hugomg
I’ve already edited the question @hugomg
– Força Chape