1

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.

closed as off-topic by Jaime, Richard Horrocks, Achala Dissanayake, Ismael, Vignesh Karthikeyan Jun 29 '18 at 21:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Ethereum, the decentralized application platform and smart contract enabled blockchain, within the scope defined in the help center." – Jaime, Richard Horrocks, Achala Dissanayake, Ismael, Vignesh Karthikeyan
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Please ask this on Stackoverflow - it's not related to Ethereum. – Richard Horrocks Jun 28 '18 at 12:27
2

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.

  • answer was found. thankyou for your time in replying. – Timujin Jun 28 '18 at 11:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.