Skip to content
Advertisement

Getting a specific element from a list of tuples

In using Spacy, I have the following:

JavaScript

It is a list of tuples. I want to extract the person element. This is what I do:

JavaScript

What would be a better way?

Advertisement

Answer

To keep all first element if second element is PERSON from first list use a list comprehension notation with a if at the end

JavaScript

This corresponds to

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