The children\'s game of Pig Latin models a secret code with a few simple rules f
ID: 3796750 • Letter: T
Question
The children's game of Pig Latin models a secret code with a few simple rules for changing words in a sentence:
- if a word begins with one consonant, that letter is moved to the end and 'ay' is appended:
pig latin --> igpay atinlay
- if a word begins with two consonants, both letters are moved to the end and 'ay' is appended:
grade --> adegray
- if a word begins with a vowel, the letter remain in place and 'way' is appended to the end of the word:
apple --> appleway
Write a Python program that accepts text input and prints out the Pig Latin translation according to the above rules. If the user enters no words, your program should print a message that the input can't be translated.
Note:
- don't worry about handling special cases such as:
numbers,
commas or other punctuation
non-latin characters
- You can use this string check whether any specific letter is a vowel:
# list of vowels
vowels = 'aeiou'
- remember to account for words that start with an upper-case letter
Extra credit - enable your program to support multi-word entries. Remember you can turn a string into a list of substrings with split(), and check each substring using a loop.
Explanation / Answer
------------------------------------------------------end of program----------------------------------------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.