Question: PYTHON: Write a program that accepts as input a sentence and converts each word to Pig Latin. use the version of Pig Latin in
PYTHON: Write a program that accepts as input a sentence and converts each word to " Pig Latin." use the version of Pig Latin in which you remove the first letter and place that letter at the end of the word. Then you append "ay" to the word.
Example: I slept most of the night
Pig Latin: lay leptsay ostmay foay hetay ightnay
Is there a different way to write this program without the use of: l[i] = l[i][1:] + l[i][0] + "ay" Have not learned this in class yet.
str = input("Enter a sentence: ")
l = str.split(" ")
for i in range(len(l)):
l[i] = l[i][1:] + l[i][0] + "ay"
str = ' '.join(l)
print("Pig Latin:",str)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
