if ('sct', 'ovc', 'clr') not in words[i]: list_stat.append(words[i]) i=i+1 print words[i] else: i=i+1 i trying create or statement in python parse list. number of keywords lot longer 3 see in if statement, nested if statements redundant quick. i'm kind of new python not in statement seemed efficient grouping of keywords together. problem is, keep getting errors trying compare tuple array. i've tried way well:
if words[i] not in ('sct', 'ovc', 'clr'): list_stat.append(words[i]) i=i+1 print words[i] else: i=i+1 neither work correctly. should mention second way runs without error, doesn't remove words list. 3 words appear individually multiple times throughout list, though whole point of not in statement rid of them. trying rid of individual instances of these words. have tried {} instead of () neither rid of individual words in list. ideas i'm doing wrong?
the errors because of indentation errors. besides this, use for loop simplify things (it i=i+1 you):
for in range(len(words)): if words[i] not in ['sct', 'ovc', 'clr']: list_stat.append(words[i]) print words[i] doesn't remove words list
either way you're populating new list (list_stat), not deleting words.
Comments
Post a Comment