Skip to content
Advertisement

get specific list by value python

I have a list of dictionary looks like this.

JavaScript

I want to get the list by the value of 'select' key. For example:

JavaScript

this one is not working because of some error list indices must be integers or slices, not str

Advertisement

Answer

New answer:

Since the original post is edited, I updated my answer.

First, If you certain that the ‘select’ value is unique and not missing,

JavaScript

will work. or, if there could be many same ‘select’ values or could be none, you can do following:

JavaScript

output:

JavaScript

Old answer:

charts is a nested list. You should iterate it.

JavaScript

output:

JavaScript

or

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement