Skip to content

Latest commit

 

History

History
42 lines (23 loc) · 615 Bytes

Simple_Pig_Latin.md

File metadata and controls

42 lines (23 loc) · 615 Bytes

CodeWars Python Solutions


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 !

Given Code

def pig_it(text):
    pass

Solution

def pig_it(text):
    return " ".join(["{}{}ay".format(c[1:], c[0]) if c.isalpha() else c for c in text.split()])

See on CodeWars.com