Skip to content
Advertisement

How to extract a sublist by the value of the first element from a nested list

I want to extract a sublist from a nested list based on the first element in each list. I have the following nested list:

JavaScript

I want to have a function which returns ['nom', 'N', 'eye'] when the first element of the sublist 'nom' is inputted, for instance:

JavaScript

How should I achieve this with python3.6+?

Advertisement

Answer

JavaScript

Output:

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