Member Avatar for pasta

Hello, i recently learned Pig Latin and how it works (some stupid hard shakespeare language in Python lol) and in CodeAcademy it says "print Pig Latin" in pig latin which i do not know how and i need some help, here is the code i entered for the program on the site as i copied it and learned it from Youtube vids, then modified it on pycharm and enjoyed it, Please help XD
(my first post)

def main():
        lst = ['sh', 'gl', 'ch', 'ph', 'tr', 'br', 'fr', 'bl', 'gr', 'st', 'sl', 'cl', 'pl', 'fl']
        sentence = input('Type what you would like translated into pig-latin and press ENTER: ')
        sentence = sentence.split()
        for k in range(len(sentence)):
                i = sentence[k]
                if i[0] in ['a', 'e', 'i', 'o', 'u']:
                        sentence[k] = i+'ay'
                elif t(i) in lst:
                        sentence[k] = i[2:]+i[:2]+'ay'
                elif i.isalpha() == False:
                        sentence[k] = i
                else:
                        sentence[k] = i[1:]+i[0]+'ay'
        return ' '.join(sentence)

def t(str):
        return str[0]+str[1]

if __name__ == "__main__":
        x = main()
        print(x)

And your question is?

@pastapengus
Your Question is not clear.... do you need help or you post the code for other to make use of it.... Pls tell the house what you want or need

Member Avatar for pasta

I mean , how do i make an interactive program with Pig Latin

If you want to translate more than one sentence, you can use a loop

if __name__ == "__main__":
    while True:
        x = main()
        print(x)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.