-3

I have below result from json file. I want to get all id's from the list of dictionaries

result = { 
           "response": [{
             "1d": 1, 
             "name": "jhon"
           },  
           {
             "1d": 2, 
             "name": "tom"
           }, 
           {
             "1d": 3, 
             "name": "peter"
           }
         ]}

expected result: [1, 2, 3]

Rafa Guillermo
  • 14,474
  • 3
  • 18
  • 54
Ashu
  • 23
  • 4
  • 2
    `[x['1d'] for x in result['response']]` – CDJB Jan 07 '20 at 15:06
  • 1
    "want" should not be used if you haven't tried anything. What have you tried ? At least as seen from description, we can't say you have tried or researched well. – mozilla-firefox Jan 07 '20 at 15:10
  • Please, avoid asking low-effort question, post some code of what you have tried, the community role is to help, not to do your homework for you, consider reading this guide about asking good questions: https://stackoverflow.com/help/how-to-ask – henriquehbr Jan 07 '20 at 15:17
  • print ([value['1d'] for value in result['response'] ]) – Luke Jan 07 '20 at 16:15

1 Answers1

0
print ([value['1d'] for value in result['response'] ])
Mayowa Ayodele
  • 549
  • 2
  • 11
  • 1
    This is showing up in the low-quality answers queue, but does answer the Question! Can you add a line about how this works? – ti7 Jan 07 '20 at 15:28