0
Pig Latin
Can someone help me with the task "Pig Latin"?
6 Answers
+ 4
In the Pig Latin task, you're given a message. You're supposed to get each word in the message, which you can separate using split() into a list. Then, you can create a new list, and loop through the first list of words. During each word, append to the new list the new version of the word, which should be the first letter of the word except for the first letter, the first letter of the word, and "ay" added together(use slicing and concatenating to accomplish this).
Try it yourself, and I may be able to help you more.
+ 1
Yeah, i've already solve it😅. I was so close
+ 1
# Pig Latin
# https://www.sololearn.com/coach/4?ref=app
def pig_latin(a):
for b in a:
print((b[1:] + b[0:1] + "ay "), end=" ")
sentence = input("Enter sentence for translation into Pig Latin: ")
x = sentence.split()
x = list(x)
pig_latin(x)
# https://www.sololearn.com/Discuss/2131423/pig-latin
# https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/trypython.asp?filename=demo_ref_string_split
# https://stackoverflow.com/questions/12032214/print-new-output-on-same-line
0
Just jumping in here to see if you can give me a hint what I am doing wrong. The words are created as they should be but I can't work out how to get then to print out in a string and not a list. Can you help?
https://code.sololearn.com/cZ1oDgN4PFN1
x = input()
x = x.split()
x = list(x)
for i in x:
x = (i[1:] + i[0] + 'ay')
print(x)
0
Alex, the print statement in the for loop shouldn't be indented. It should be:
print(" ".join(s))
By the way, please don't post questions in another thread. You can post your own question.
0
Here is how did it:-
x=""
for i in input().split():
x += i[1:] + i[0:1] + "ay "
print (x)