Skip to content
Advertisement

Filter list of dictionaries from a value and get items forward [closed]

I have this list of dictionaries, for example:

JavaScript

So how would it be if I wanted to get the values of the list from an element that I choose. If I choose a:0, it should return all elements of this forward. It would be like this:

JavaScript

if I choose:-1: it should return this:

JavaScript

Also, how would it be if it is proposed that the same selection be included in the list?

Advertisement

Answer

Here’s a function to walk the list and return all the items after the dictionary containing a certain key/value:

JavaScript

Output:

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