python - Remove element out of tuple -


i have tuple in moy code:

('h', 'nnp') 

this code:

# -*- coding: utf-8 -*- nltk.corpus import wordnet wn nltk import pos_tag import nltk syno =[]   sentence = '''his father suggested study become parson instead, darwin far more inclined study natural history.darwindar·win (där'wĭn),charles robert.1809-1882.british naturalist revolutionized study of biology theory ofevolutionbased on natural selection several scientists before him, darwin believed life on earth evolved (developed gradually) on millions of years few common ancestors.''' sent = pos_tag(sentence)  alpha = [s s in sent if s[1] == 'nnp'] in range(0,len(alpha)-1):     print alpha[i] #return tuple 

i want remove h this. how can so?

tuples immutable, have make new one:

>>> t = ('h', 'nnp') >>> tuple(x x in t if x != 'h') ('nnp',) >>> z = tuple(x x in t if x == 'h') >>> z ('h',) >>> z[0] 'h' >>> 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

java - SmsManager sending message more than one -