Skip to content

Commit b0e18ac

Browse files
authored
Update piglatintranslator.py
1 parent 2277ca9 commit b0e18ac

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

BasicPythonScripts/Piglatin Translator/piglatintranslator.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
def englishtopiglatin(s):
33
# splits string by words and passed into list
44
s = s.lower().split(" ")
5-
65
result = ""
76

87
# for every string in the list translate to pig latin through the formula before
98
for string in s:
10-
result += (string[1:] + string[:1] + "ay" + " ")
9+
10+
if (len(string) <= 1):
11+
result += (string + "way")
12+
else:
13+
result += (string[1:] + string[:1] + "ay" + " ")
1114

1215
# return new string
1316
return result

0 commit comments

Comments
 (0)