Created
July 31, 2020 11:51
-
-
Save kshirsagarsiddharth/6e023910efaff6ec4af9f7ddd1760b99 to your computer and use it in GitHub Desktop.
pig latin translator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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