Write a program that reads a sentence from the user and conv
Solution
Please find the required program along with its output. Please see the comments against each line to understand the step.
def piglatin():
wordsInSentence = str(input(\"Enter the input sentence to convert to pig-Latin: \")).split() #read the user input sentence which needs to be converted to pig-Latin, and split it into individual words
for word in wordsInSentence: #to print the user input in normal english
print (word,end = \" \")
print() #for newline
for word in wordsInSentence: #iterate through each word in the sentence
print(word[1:] + word[0] + \"ay\", end = \" \") # word[1:] will truncate the words first character; word[0] will print the first character of the word; and then add ay to the end
print () #for newline
piglatin()
------------------------------------------
OUTPUT:
