I have a script in a For loop that builds a list of lists with the results of my search. To each list I need to add a "variable" value. This is my code:
root = ET.fromstring(resp)
data = root.findall('.//row')
for datum in data:
entries = datum.findall('.//col')
datos.append([entry.text.strip()
for entry in entries[:5]])
I get the following result:
[['peras', '20', 'Acme'], ['bananas', '35', 'Zero'], ['sandias', '45', 'Lion']]
I want to get the following result by adding a new value to the end of each list:
[['peras', '20', 'Acme', 'AR'], ['bananas', '35', 'Zero', 'UY'], ['sandias', '45', 'Lion', 'BR']]
I am trying the following:
datos.append(codigo)
But the new value is added to me outside of each list:
[['peras', '20', 'Acme'], 'AR', ['bananas', '35', 'Zero'], 'UY', ['sandias', '45', 'Lion'], 'BR']
I'm using Python 3.6. Could you give me a hand? Thank you very much