How to sum values from a request:

0

Example:

request = requests.get('https://api.amountofsomething.com')
quantidade = requisição.json()['amount']

This request returns the quantity, for example: {[{25}{120}{158}{0}{2}{10}]}

I need to add values without patterns. I tried this way:

amount0 = amount[0]['amount']

amount1 = amount[1]['amount']

amount2 = amount[2]['amount']

sum0 = amount0+amount02
...

For large amounts of data, the code will be too large. I tried these ways:

sum0 =  amount [0+2]['amount']

sum1 = amount [[1] + [18]]['amount']

sum2 = amount [0]['amount'] + amount [1]['amount']

Neither option worked. Can anyone help me?

    
asked by anonymous 09.08.2018 / 05:06

0 answers