0
pig_latin: join or append? (solved - it was both!)
My code is just printing the last word in the string. I'm thinking maybe I should amend but not sure what can and should be amended. Any pointers would be great. Thanks. https://code.sololearn.com/cZ1oDgN4PFN1 x = input() x = x.split() x = list(x) for i in x: x = (i[1:] + i[0] + 'ay') print(''.join(x))
4 Réponses
+ 1
It should look like this. You're referencing x over and over again, so it doesn't work.
https://code.sololearn.com/cRiDjZRbYsEZ/?ref=app
+ 1
Alex, sorry, my mistake. I have changed it.
+ 1
Nice one. Cheers. Makes perfect sense with the added []. That's what I was missing all along. All the iterations without them is what led me to having all the x!
https://code.sololearn.com/cZ1oDgN4PFN1
0
Thanks. Your code just prints out the words as they are entered. I've got this far:
https://code.sololearn.com/cZ1oDgN4PFN1
#Only the last word is printed? How come y does not join?
x = input().split()
for i in x:
y = (i[1:] + i[0] + 'ay')
print(''.join(y))
An aside how is .split() any different to creating a list?