PYTHON
Question 7 (Pig Latin Word; 12 points)
Pig Latin is a fun and simple version of encrypting information: it converts a supplied word to a new word that is confusing if you don't understand the rules involved. There are many variants, but we'll use the following rules:
If the first letter in the word is "a", "e", "i", "o", or "u" (i.e., a vowel, not including "y"), add "way" to the end of the word.
Otherwise, look to the rest of the word (left-to-right) for the first letter that is "a", "e", "i", "o", "u", or "y" (i.e., a vowel, this time including "y"); move all characters before it to the end of the word; and then add "ay" to the end of that word.
For example...
>>> hw5.pig_latin_word('alpha')
'alphaway'
>>> hw5.pig_latin_word('bravo')
'avobray'
>>> hw5.pig_latin_word('yankee')
'ankeeyay'
>>> hw5.pig_latin_word('byline')
'ylinebay'
To receive credit, your code for this problem MUST use your is_vowel function (i.e., you should NOT re-implement determining whether a letter is a vowel in a particular context).
# input: word to convert (assumed lowercase)
# output: if first letter is a vowel add "way" to the end;
# otherwise find the first vowel, move
# beginning to end + "ay"
def pig_latin_word(s):
return "" # your code here!