0

I hope everyone is having a good day. I want to access the elements within a list of dictionaries, and a dictionary within a dictionary by using FOR LOOP. Or is there any other way to do this? I hope you can get me the idea. Thanks in advance. The sample data is here:

listv = {'attached_volumes': [{'id': '1b33b33f-8e92-4068-a459-0a1de0febb7c'}, {'id': 'c56502b9-0632-4f9f-88b9-70f40e61ef5d'}]}

The ids could be more than one.

blizzy
  • 55
  • 6
  • see here: https://stackoverflow.com/questions/6027558/flatten-nested-dictionaries-compressing-keys – gregory Apr 17 '21 at 06:07
  • ``` for k,v in listv.items(): for d in v: d_id = d["id"] ``` – Marsilinou Zaky Apr 17 '21 at 06:11
  • Sounds like you might be looking for a recursive solution. If you add the output that you are trying to get from your example input that will help us give a more direct answer. – LPR Apr 17 '21 at 06:17

0 Answers0