In: Computer Science
Write a function in python that accepts a sentence as the argument and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHTPIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY. Please, I want the coding indented and then the results screen shot.
inp=input("Enter sentene in capslok : ") #input from
user
lst=inp.split(" ") #splitting the words in to
list
s="" #empty string for storing result
#coverting english latin
for word in lst:
l=len(word) #finding length of every word
in list named lst
if(l==0): #if length of word equal to zero
then no remove of frist letter
s=s+(word[0:]+"AY"+" ")
else: #if length of more than 0 than
remove first letter of word
s=s+(word[1:]+word[0]+"AY"+"
")
print(s) #displaying resultant string