For example, I have this dictionary.
{'count': 1, 'items': [{'date': 1649523732, 'from_id': 269690832, 'id': 190, 'out': 0, 'attachments': [{'type': 'photo', 'photo': {'album_id': -3, 'date': 1649523732, **'id': 457249932**, 'owner_id': 269690832, 'access_key': 'df14603asdd3d26e7a1f5'}}]}]}
I want to get the value of id ('id': 457249932). How do i do this?
CodePudding user response:
The element is nested quite deep -- it's nested inside a list mapped to an items
key, a list mapped to an attachments
key, and a dictionary mapped to a photo
key. So, we can do:
print(data['items'][0]['attachments'][0]['photo']['id'])
where data
is the dictionary that you're indexing on.