[Tutor] Splitting on punctuation
Andreas Perstinger
andipersti at gmail.com
Mon Jun 10 10:21:04 CEST 2013
On 09.06.2013 01:44, Mike Nickey wrote:
> Give the input of "which isn't that surprising I guess.",",'.") where the
> first part passed is the string and the second part is the punctuation to
> split on, I'm having difficulty converting the punctuation to a split
> parameter.
Read about the "translate" method to map every punctuation character to
whitespace and the just use "split" on the translated string:
http://docs.python.org/3/library/stdtypes.html#str.translate
Bye, Andreas
More information about the Tutor
mailing list