Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

PigLatin Sentence Translator Help

What I want me code to do is be able to take a sentence from a user input and output each word in that sentence in Pig Latin form. If I enter "hello there" it says ellohay, it is only printing the first word in pig latin. I am also having trouble with running code in different applications and stuff like that. It won't work in BBEdit or Terminal, but it will in JupterLab. So I would also appreciate it if any could recommend some software for a Mac because I think the software I'm using might be the problem.
def pig():

sentence = input("Enter a sentence: ")


for word in sentence.split():

first_letter = word[0]

if first_letter in "aeiou":

word = word + "ay"
return word

else:

word = word[1:] + first_letter + "ay"
return word

newsent = (" ".join(sentence.split()))
print(newsent)


pig()
by

0 Answers

No Answer posted yet.

Login / Signup to Answer the Question.