Easy way to break up a sentence?

Paolo Invernizzi paoloinvernizzi at dmsware.com
Wed Oct 2 09:46:31 EDT 2002


> Eg, something like this:
> from: "This is an example"
> to: ["This", "is", "an", "example"]


If the separator is constant, .split method is what you are searching.

 >>> "This is an example".split()
['This', 'is', 'an', 'example']
 >>>

Check also the RE module, for splitting based on regular expression...

Paolo Invernizzi
DMSWare.com




More information about the Python-list mailing list