Can someone help me with the task "Pig Latin"?
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.
Yeah, i've already solve it😅. I was so close
# 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/python/trypython.asp?filename=demo_ref_string_split # https://stackoverflow.com/questions/12032214/print-new-output-on-same-line
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 + 'ay') print(x)
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.
Here is how did it:- x="" for i in input().split(): x += i[1:] + i[0:1] + "ay " print (x)
difference in while loop
What is input?
Decimal to Hex in C++