+ 2

Why is this Pig Latin solution wrong?

I've solve the Pig Latin in Python in a couple of ways. These ways were using a variable to save the words translation and were passing the Test 1, 2 and 5 correctly. Despite that I tried by slicing the input then printing the words and it worked that way. Yet I want to know why my first solving wasn't correct and if it's a good solution in terms of software quality. https://code.sololearn.com/c91kDatvjR6s/?ref=app

10th Sep 2021, 5:49 PM
JhMont
JhMont - avatar
9 ответов
+ 2
The first letter is deleted in the whole word and only once added at the end plus the ay.
10th Sep 2021, 6:37 PM
Coding Cat
Coding Cat - avatar
+ 1
I got an unexpected result for input "aa" Output is: aay Expected is: aaay
10th Sep 2021, 6:12 PM
Coding Cat
Coding Cat - avatar
+ 1
Or this one Input: aba Output: baay Expected: baaay
10th Sep 2021, 6:29 PM
Coding Cat
Coding Cat - avatar
+ 1
10th Sep 2021, 6:32 PM
JhMont
JhMont - avatar
+ 1
Thanks for answering. Now I know why that wasn't working in those tests. I had to debug it better.
10th Sep 2021, 6:55 PM
JhMont
JhMont - avatar
11th Sep 2021, 5:07 AM
Mayank Gupta
Mayank Gupta - avatar
+ 1
x="" for i in input().split(): x += i[1:] + i[0] + "ay " print (x)
11th Sep 2021, 3:33 PM
CGO!
CGO! - avatar
0
It may come from the space after the string you add, "ay ", which could add an extra space at the end of the output string ?
10th Sep 2021, 6:08 PM
Delorme
0
JhMont Delorme the space at the end is ok. I have passed all cases with such a space at the end.
10th Sep 2021, 6:15 PM
Coding Cat
Coding Cat - avatar