Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help to create pig latin translator in Python ‘Pig Latin’ Translation rules

ID: 664112 • Letter: N

Question

Need help to create pig latin translator in Python

‘Pig Latin’ Translation rules

1.   If a word has no letters, don't translate it.
2.   All punctuation should be preserved.
3.   If the word begins with a capital letter, then the translated word should too.
4. Separate each word into two parts. The first part is called the prefix and extends from the beginning of the word up to, but not including, the first vowel. (The letter y will be considered a vowel for this.) The Rest of the word is called the stem.
5.   The Pig Latin text is formed by reversing the order of the prefix and stem and adding the letters ‘ay’ to the end. For example, sandwich is composed of s + andwich which would translate to andwichsay.
6.   If the word contains no consonants or starts with a vowel, let the prefix be empty and the word be the stem. The word ending should be yay instead of merely ay. For example, I would be Iyay and understood would be understoodyay.

Phase 1

Your first task is to produce a function called pl_prefix that takes one argument, a string containing a word, and returns the portion of the word up to, but not including the first vowel. For example, if you sent 'banana' to your function, it should return 'b'. Sending 'Sibley' should return 'S', 'stream' should return 'str', and 'break' should return 'br'. Test your function with other words and print out the results.

Explanation / Answer

-----