Answer the question
In order to leave comments, you need to log in
How to return the value of a dictionary key that is in a nested dictionary?
I am writing a simple program in Python3, the following problem arose:
There is a json response:
{
"response": [{
"id": 11111,
"first_name": "Blah-Blah",
"last_name": "Lalalala",
"city": {
"id": 2,
"title": "Санкт-Петербург"
}
}]
}
Answer the question
In order to leave comments, you need to log in
for response in content['response']:
print(response.get('city', {}).get('title', ""))
Here's a dear link.
Find all occurences of a key in nested python dict...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question