0

I hope you are having a great day. I want to convert these dictionary values into a list. Can anyone give me the idea? Thanks in advance.

Here is the sample data:

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

And the output would be like this:

['1b33b33f-8e92-4068-a459-0a1de0febb7c', 'c56502b9-0632-4f9f-88b9-70f40e61ef5d']
1
  • print([i['id'] for i in listb]) ? Commented Apr 17, 2021 at 9:08

1 Answer 1

1

You could use a list-comprehension to solve this (assuming that the key is always id):

[el["id"] for el in listb]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.