chad <cdal...@gmail.com> writes:

> Let's say that I have an article. What I want to do is read in this
> file and have the program skip over ever instance of the words "the",
> "and",  "or", and "but". What would be the general strategy for
> attacking a problem like this?

Something like (untested):

    stopwords = set (('and', 'or', 'but'))

    def goodwords():
      for line in file:
         for w in line.split():
            if w.lower() not in stopwords:
               yield w

Removing punctuation is left as an exercise.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to