Computer Science, asked by kshitizshreyashkar, 8 months ago

1 point
2. Let's create a function that turns text into pig latin: a simple text transformation that modifies each word moving the first
character to the end and appending "ay" to the end. For example, python ends up as ythonpay.
1
2
def pig_latin(text):
say =
# Separate the text into words
words
for word in words:
# Create the pig latin word and add it to the list
4
OD 1 W
7
1000
# Turn the list back into a phrase
return
Run
18
11
print(pig_latin("hello how are you")) # Should be "ellohay owhay reaay ouyay"
print(pig_latin("programming in python is fun")) # Should be "rogrammingpay niay ythonplay si
12​

Answers

Answered by sachinvns2110
3

Explanation:

Let's create a function that turns text into pig latin: a simple text transformation that modifies each word moving the first character to the end and appending "ay" to the end. For example, python ends up as ythonpay?

Your child can be the next tech innovator. Start early.

def pig_latin(text):

say = ""

# Separate the text into words

words = text.split()

for word in words:

# Create the pig latin word and add it to the list

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

say += texts

# Turn the list back into a phrase

return say

print(pig_latin("hello how are you")) # Should be "ellohay owhay reaay ouyay"

print(pig_latin("programming in python is fun")) # Should be "rogrammingpay niay ythonpay siay unfay"

Answered by juwairiaadel
0

Answer:

def pig_latin(text):

 say = ""

 i=0

 # Separate the text into words

 words = text.split()

 for i in words:

     firstLetter=i[0]

     newWord=i[1:]+firstLetter+"ay"

     say += newWord +" "

 return say

print(pig_latin("hello how are you")) # Should be "ellohay owhay reaay ouyay"

print(pig_latin("programming in python is fun")) # Should be "rogrammingpay niay ythonpay siay unfay"

Explanation:

Similar questions