Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python question

Name: Anonymous 2011-12-20 5:33

How can I remove all the words in one list from another list without loosing duplicates or order?

eg:

aList = ['so', 'what', 'man', 'what']

noiseWords = ['so', 'um', 'crap']

I want aList without the 'so' in noiseWords.
Using Python 3.1 btw, thanks for any help.

Name: Anonymous 2011-12-20 7:56

what if noisewors contains a word twice?

if that never happens, i'd go with something like:


done = []
[a for a in aList if a not in noiseWords and ++(done[a]) == 1]

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List