Ask Question
16 September, 13:17

Write a function to_pig_latin that converts a word into pig latin, by: Removing the first character from the start of the string, Adding the first character to the end of the string, Adding "ay" to the end of the string. So, for example, this function converts "hello"to "ellohay". Call the function twice to demonstrate the behavior. There is a worked example for this kind of problem.

+2
Answers (1)
  1. 16 September, 16:19
    0
    def to_pig_latin (word):

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

    return new_word

    print (to_pig_latin ("hello"))

    print (to_pig_latin ("latin"))

    Explanation:

    Create a function called to_pig_latin that takes one parameter, word

    Inside the function, create a new_word variable and set it to the characters that are between the second character and the last character (both included) of the word (use slicing) + first character of the word + "ay". Then, return the new_word.

    Call the to_pig_latin function twice, first pass the "hello" as parameter, and then pass the "latin" as parameter
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a function to_pig_latin that converts a word into pig latin, by: Removing the first character from the start of the string, Adding ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers