[Tutor] A string-manipulation question
agilfoy at frontiernet.net
Fri Mar 30 02:49:48 CEST 2007
Awesome! (I was hoping it would be a 1-line solution. :)
Thanks to batteries beign included, I don't necessarily need to worry
about why and how .spilt() works. :)
Quoting Bob Gailer <bgailer at alum.rpi.edu>:
> Alan Gilfoy wrote:
>> Hi. I want to learn how to "break down" a string into its component
>> words, and then process each word somehow.
>> Is there a way in Python to separate a string into its component words.
>> Like this:
>> "I would like to convert an English string (sentence) into Pig Latin."
>> The Pig Latin conversion I think I can handle already (if not, I'll
>> cross that bridge when I come to it.) However, what I want help
>> on is how to make each word of the string a separate value, or at
>> least make it able to index the string by word, as opposed to the
>> standard method of strings being indexed by character.
> "I would like to convert an English string (sentence) into Pig
> ["I", "would", "like", "to", "convert", "an", "English", "string",
> "(sentence)", "into", "Pig Latin."]
> Bob Gailer
More information about the Tutor