[Tutor] can this be done easerly
alan.gauld at btinternet.com
Mon Aug 30 19:01:04 CEST 2010
> I tried your suggestion with strip and it looks like this :
> import string
You don't need this now
> def extract_words(s):
> word= ""
You dont need this
> s = string.lower(s)
> s = s.replace( "--", " ")
You probably don't need this either - just add '-' to the strip set.
> s = s.split()
> for word in s:
And you could combine those to
for word in s.split():
> test = word
> test = word.strip('!?,.')
You don't need test, just use
word = word.strip('!?",.-') #added " and - to your set...
> return s2
> It works well only I can't get it to work the strip with ".
> I always get a EOF error message. I tried it with
> word.strip('!?,.") and with word.strip('!?,./"'') but no go.
It looks like you are mixing quote styles.
Notice how I included the " in the strip() above...
See if that works for you.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor