Translating sentences in PygLatin


Hello everybody! I was able to make a translator, but it only translates one word. I really don't understand how to make it possible to translate a sentence with multiple words.

Hope someone can help me!

#List Operators
vowels = ["a", "e", "i", "o", "u"]
consonants = ["b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z"]

print ("Program to translate sentences to pig latin.")
print ("Avoid using symbols and punctuation.")

#Define word
word= ""
while word != "exit":
    word = input("Enter a word to translate or Exit: ")
    if word.isalpha():
        word = str(word)
#Translate word by checking how it starts
        first_letter = word[0]
        second_letter = word[1]
        if first_letter in vowels:
            print (word + "yay\n")
            if first_letter and second_letter in consonants:
                print (word[2:] + word[:2] + "ay\n")
                print (word[1:] + word[0] + "ay\n")

        if word.lower() == "exit":
            word = word.lower()
            print("Invalid character! Try again.\n")


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.