Goat Latin LeetCode solution in Python

1
class Solution:
2
def toGoatLatin(self, sentence: str) -> str:
3
wordList, result, index = sentence.split(" "), "", 1
4
for word in wordList:
5
if index > 1:
6
result += " "
7
firstLetter = word[0]
8
if firstLetter in "aeiouAEIOU":
9
result += word + "ma"
10
else:
11
result += word[1:] + firstLetter + "ma"
12
for i in range(index):
13
result += "a"
14
index += 1
15
return result

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0