345.反转字符串中的元音字母
描述
编写一个函数,以字符串作为输入,反转该字符串中的元音字母。
示例
给定 s = “hello”, 返回 “holle”.
给定 s = “leetcode”, 返回 “leotcede”.
元音字母不包括 “y”.
思路:元音字母a,o,i,e,u。首先按序找出字符串中的元音字母,记录下索引值存放在列表index_list中,然后进行倒序。
我
class Solution:
def reverseVowels(self, s):
"""
:type s: str
:rtype: str
"""
l = ['a','o','e','u','i','A','O','E','U','I']
res = list(s)
index_list = []
for i in range