[Tutor] A string-manipulation question
bgailer at alum.rpi.edu
Fri Mar 30 01:35:16 CEST 2007
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 Latin.".split()
["I", "would", "like", "to", "convert", "an", "English", "string",
"(sentence)", "into", "Pig Latin."]
More information about the Tutor