Skip to content

Instantly share code, notes, and snippets.

@kshirsagarsiddharth
Created July 31, 2020 11:51
Show Gist options
  • Select an option

  • Save kshirsagarsiddharth/6e023910efaff6ec4af9f7ddd1760b99 to your computer and use it in GitHub Desktop.

Select an option

Save kshirsagarsiddharth/6e023910efaff6ec4af9f7ddd1760b99 to your computer and use it in GitHub Desktop.
pig latin translator
def pig_latin_sentence(sent):
output = []
for word in sent.split():
if word[0] in "aeiou":
output.append(word + "ay")
else:
output.append(word[1:] + word[0] + "ay")
return " ".join(output)
def pl_translate():
sentence = ""
while True:
sentence = yield pig_latin_sentence(sentence)
if sentence is None:
break
g = pl_translate()
print(next(g))
print(g.send("Python is so awesome right"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment