0
Simplify Pig latin code
You have two friends who are speaking Pig Latin to each other! Pig Latin is the same words in the same order except that you take the first letter of each word and put it on the end, then you add 'ay' to the end of that. ("road" = "oadray") Task Your task is to take a sentence in English and turn it into the same sentence in Pig Latin! Input Format A string of the sentence in English that you need to translate into Pig Latin. (no punctuation or capitalization) Output Format A string of the same sentence in Pig Latin. Sample Input "nevermind youve got them" Sample Output "evermindnay ouveyay otgay hemtay" https://code.sololearn.com/cwVk56LaR7we/?ref=app
3 odpowiedzi
+ 3
maybe there is simplier version but i dont use python very frequently
words = input().split();
sentence = '';
for word in words:
sentence += word[1:] + word[0:1] + 'ay '
print(sentence[:len(sentence) - 1])
+ 2
one liner , not much readable maybe but hopefully it helpe you somehow ..
a="nevermind youve got them"
print(" ".join(list(i[1:]+i[0]+"ay" for i in a.split(" "))))
+ 1
sentence = input().split()
pig_latin = [f"{word[1:]}{word[0]}ay" for word in sentence]
print(" ".join(pig_latin))