LeetCode824.Goat Latin
class Solution:
def toGoatLatin(self, S):
"""
:type S: str
:rtype: str
"""
sList = S.split()
ch = ''
for item in sList:
index = sList.index(item)
if item[0] in "aeiouAEIOU":
ch = item + "ma"
sList[index] = ch
else:
ch = item[1:] + item[0] + "ma"
sList[index] = ch
ch = ''
lastIndex = -1
for item in sList:
index = sList.index(item, lastIndex + 1)
lastIndex = index
ch += item + 'a'*(index + 1) + " "
return ch[:len(ch)-1]