0

I am receiving a python dict that has the following format via curl.

json = connect(header, URL)

python dict

I am trying to iterate/get the different "number" values with the following code:

for i in json['mail']['number']: 

    print (str(i).replace('"',''))

but it does not work. Any ideas?

2
  • Can you please copy paste you dict, so we can easily figure out what's going wrong Commented Mar 13, 2021 at 9:58
  • Share some part of dictionary in your code Commented Mar 13, 2021 at 9:58

1 Answer 1

1

You're iterating over the wrong object, try this:

for i in json['mail']:
    print(int(i['number']))

Please also note: naming a variable json could be very bad because most likely you are using the json package as well and this will lead to naming conflicts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.