Computer Science, asked by kumarsharmaharsh, 10 months ago

Twisted Pig Latin. Prompt the user to enter a single word. Then form a new word by
taking the first letter of the original word, moving it to the end, and adding “ay". Thus
"school" becomes "choolsay".write a program in python by using conditional sentence in python​

Answers

Answered by Anonymous
14

Explanation:

//a piglatin python 3.1 or above program

while(True):

s=input("enter the word")

if(s.find(' ')==-1):

break

print (s[1:],s[0],"ay")

Answered by poojan
1

Python program to form a new word.

Program :

word=str(input())

if len(word)==1:

   new_word=word+"ay"

else:

   new_word=word[1:]+word[0:1]+"ay"

print("new word formed is : ", new_word)

Testcases :

Input 1 : (String whose length is >1)

school

Output 1:

new word formed is : choolsay

Input 2: (String whose length is 1)

x

Output 2:

new word formed is :  xay

Explanation :

  • Take a string as an input from the user.

  • If it's length is 1, concatenate the string with "ay" at the end, directly, store the string in a variable.

  • If the length of the string is greater than 1, slice the string from index 1 to the end and then, next to it, concatenate it with the letter at index 0 and add "at" at the end, store the string in a variable.

  • Print the variable.

Learn more :

  • Advantages of Programming in python

      brainly.in/question/11007952

  • Indentation is must in python. Know more about it at :

       brainly.in/question/17731168

Attachments:
Similar questions