Skip to content

Commit d7ecd4e

Browse files
committed
Update pig_latin.py
1 parent 872220e commit d7ecd4e

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pig-latin/pig_latin.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,31 @@ def process_text(text: str) -> str:
3333
# or starts with "xr" or "yt",
3434
# add an "ay" sound to the end of the word.
3535
return text + "ay"
36+
3637
# Rule 2
37-
elif is_rule_2(text):
38+
if is_rule_2(text):
3839
# If a word begins with one or more consonants, first move those consonants
3940
# to the end of the word and then add an "ay" sound to the end of the word.
4041
i = get_last_consonant_indx(text)
4142
return text[i + 1 :] + text[: i + 1] + "ay"
43+
4244
# Rule 3
43-
elif is_rule_3(text):
45+
if is_rule_3(text):
4446
# If a word starts with zero or more consonants followed by "qu", first move
4547
# those consonants (if any) and the "qu" part to the end of the word, and then
4648
# add an "ay" sound to the end of the word.
4749
i = text.index("qu")
4850
return text[i + 2 :] + text[: i + 2] + "ay"
49-
# Rule 4
50-
elif is_rule_4(text):
51+
52+
Rule 4
53+
if is_rule_4(text):
5154
# If a word starts with one or more consonants followed by "y", first move the
5255
# consonants preceding the "y" to the end of the word, and then add an "ay" sound
5356
# to the end of the word.
5457
i = text.index("y")
5558
return text[i:] + text[:i] + "ay"
56-
else:
57-
raise ValueError(f"Unhandled word in Pig Latin translation: '{text}'")
59+
60+
raise ValueError(f"Unhandled word in Pig Latin translation: '{text}'")
5861

5962

6063
def is_rule_1(text: str) -> bool:

0 commit comments

Comments
 (0)