Last active
June 7, 2016 03:43
-
-
Save dfenjves/6f054dd0be43c164713e549e92e7bb8e to your computer and use it in GitHub Desktop.
This file contains 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_latinize_word(word): | |
vowels = ["a", "e", "i", "o", "u"] | |
if word[0].lower() in vowels: | |
pig_latin_word = word + "ay" | |
else: | |
if word[1].lower() not in vowels: | |
first_letters = word[:2] | |
rest_of_word = word[2:] | |
pig_latin_word = rest_of_word + first_letters + "ay" | |
else: | |
first_letter = word[0] | |
rest_of_word = word[1:] | |
pig_latin_word = rest_of_word + first_letter + "ay" | |
return pig_latin_word | |
def pig_latinize_phrase(phrase): | |
words = phrase.split(" ") | |
pl_words = [] | |
for word in words: | |
pl_words.append(pig_latinize_word(word)) | |
final_string = " ".join(pl_words) | |
return final_string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment