Home > database >  How to extract only the desired text using for loop
How to extract only the desired text using for loop

Time:10-20

So I have list of Tibetan words with their POS tag as shown below:

ད་གདོད DET
ད་གཟོད PART
ད་ཏྲིག NO_POS
ད་དུང PART
ད་དྲག NOUN

How can I strip out these POS tags and output only the below:

ད་གདོད
ད་གཟོད
ད་ཏྲིག 
ད་དུང 
ད་དྲག 

CodePudding user response:

[x.split(" ")[0] for x in list_]

returns

['ད་གདོད', 'ད་གཟོད', 'ད་ཏྲིག', 'ད་དུང', 'ད་དྲག']

if you want printing then this:

for x in list_:
    print(x.split(" ")[0])

prints out:

ད་གདོད
ད་གཟོད
ད་ཏྲིག
ད་དུང
ད་དྲག
  • Related