Simple Pig Latin
Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched.
Examples
pig_it('Pig latin is cool') # igPay atinlay siay oolcay
pig_it('Hello world !') # elloHay orldway !
def pig_it(text):
words=text.split(" ")
op=[]
punct='''!()-[]{};:'"\,<>./?@#$%^&*_~'''
for word in words:
if word in punct:
op.append(word)
else:
res=word[1:]+word[0]+"ay"
op.append(res)
return " ".join(op)
0 Comments
Post a Comment