824. 山羊拉丁文

exiaohu 于 2022-04-21 发布

题目链接:824. 山羊拉丁文

按照规则生成山羊拉丁文。

class Solution:
    def toGoatLatin(self, sentence: str) -> str:
        def convert(i: int, w: str) -> str:
            if w[0].lower() not in ('a', 'e', 'i', 'o', 'u'):
                w = w[1:] + w[0]
            return w + 'ma' + 'a' * (i + 1)

        return ' '.join([convert(i, w) for i, w in enumerate(sentence.split())])