Q:

How to print out tags in python

If I have a string such as this:
text = "They refuse to permit us."

txt = nltk.word_tokenize(text)

With this if I print POS tags; nltk.pos_tag(txt) I get 

[('They','PRP'), ('refuse', 'VBP'), ('to', 'TO'), ('permit', 'VB'), ('us', 'PRP')]

How can I print out only this:

['PRP', 'VBP', 'TO', 'VB', 'PRP']

A:

You got a list of tuples, you should iterate through it to get only the second element of each tuple.
>>> tagged = nltk.pos_tag(txt)
>>> tags =  [ e[1] for e in tagged]
>>> tags
['PRP', 'VBP', 'TO', 'VB', 'PRP'] 

