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