Converting a sentence to piglatin in Python

Here is a quick one

def main():
    words = str(input("Input Sentence:")).split()
    for word in words:
        print(word[1:] + word[0] + "ay", end = " ")
    print ()

main()

A better solution would probably use list comprehension so you could actually use the output, but this does what you asked.

EDIT: This works for python3.x If you want it to work for python2 you are going to have a bit more fun. Just add the strings together for each word, then print the result string.

Leave a Comment