Mapping and Filtering Help for Lists

Eric Wertman ewertman at gmail.com
Sun Apr 27 13:21:45 EDT 2008


You should check out the sets module:

http://docs.python.org/lib/module-sets.html



>
>  The problem asks to create a "compareandremove" so that you can use it on a
>  string, to remove the words from the string that are contained in un_words.
>
>  The remaining words then need to be compared to the alterns list and either
>  bring back the word if no matches or bring back the list.  To better explain
>  that i'll use an example.
>
>  If i do   compareandremove('notepad a pencil with desk')
>
>  I need it so it removes words contained in un_words, so "a" and "with";
>  then compares the remaining words to alterns to find a match.
>
>  This should bring back:
>
>  ['notepad', 'book', 'textbook', 'pencil', 'pen', 'pacer', 'desk']



More information about the Python-list mailing list