[Tutor] A string-manipulation question
Bob Gailer
bgailer at alum.rpi.edu
Fri Mar 30 23:54:17 CEST 2007
HouseScript at comcast.net wrote:
> Alan Gilfoy wrote:
>
> > Is there a way in Python to separate a string into its component words.
> you could do something like this:
> >>> x = Is there a way in Python to seperate a string into its
> compontent words.
> >>> x.split()
> that would yield:
> ['Is', 'there', 'a', 'way', 'in', 'Python', 'to', 'separate', 'a',
> 'string', 'into', 'its', 'component', 'words.']
> As far as teh translating to pig latin.....well I honestly don't know.
From Wikipedia, the rules are:
1. For words that begin with consonant
<http://en.wikipedia.org/wiki/Consonant> sounds, move the initial
consonant or consonant cluster
<http://en.wikipedia.org/wiki/Consonant_cluster> to the end of the
word and add "ay." Examples:
* fatso → atso-fay
* button → /utton-bay/
* star → /ar-stay/
* three → /ee-thray/
* question → /estion-quay/
2. For words that begin with vowel
<http://en.wikipedia.org/wiki/Vowel> sounds (including silent
consonants <http://en.wikipedia.org/wiki/Silent_letter>), simply
add the syllable "ay" to the end of the word.
* eagle → /eagle-ay/
* America → /America-ay/
* honor → /honor-ay/
Seems pretty straightforward to translate to Python (or any other
language). The only "hitch" I see is how one tells that an initial
consonant is a vowel sound or not. (honor vs home)?
opehay isthay elphay
--
Bob Gailer
510-978-4454
More information about the Tutor
mailing list