[Ethereum] dictionaries inside lists – python

python

i'm trying to access a dictionary within a list and cannot seem to get my for loop to get the key, then the value…

i've place an image herein so that its easy for me to explain.

enter image description here

so you can see, i would like to navigate to currency = AUD and assign the balance value to a variable, call it aud_balance =

for curr in result_bal_qrp:
for k in curr:
if curr[k] == 'AUD':

I cannot seem to get the key AUD… so im officially stuck.

I've tried to search for dictionary inside of lists etc but no examples of my problem, or maybe ive understood my problem wrong (highly likely)

Any help is appreciated.

Best Answer

The question could be a bit clearer. This snippet should be good to iterate over your list

for item in result_bal_qrp:
    currency = item['currency']
    balance = item['balance'] # or to edit do item['balance'] = 0

I would suggest watching a Python tutorial before delving deeper into your project.

Related Topic