+ 2
Hey, my code works, but didn't pass on test 4, and i don't unsderstand why. Pls someone help me about it
Pig latin
6 Réponses
+ 3
Why are you using a condition?
sentence = input()
pig_latin =''
words = sentence.split()
for word in words:
pig_latin = pig_latin + word[1:] + word[0] + 'ay '
print(pig_latin)
+ 2
At first I did not pay attention to your condition, because of unnecessary, presumably that the problem is in it, but looking now I can say that the code must pass all tests.
The condition compares each word with the last in the sentence.
I would make it easier:
print(pig_latin[:-1]) ☺️
+ 1
sentence = input()
pig_latin =''
words = sentence.split()
for word in words:
if word not in words[-1]:
pig_latin = pig_latin + word[1:] + word[0] + 'ay' + ' '
else:
pig_latin = pig_latin + word[1:] + word[0] + 'ay'
print(pig_latin)
+ 1
I'm using the condition to have a space between different words, and with the last word there is no need
+ 1
Don't worry about it, testing is not responsive to this. Or do you want to do this for yourself?
+ 1
In fact i wanna do that for myself, to have a code that works better. But thank you