classSolution(object):defreverseVowels(self,s):""" :type s: str :rtype: str """ vowels ={'a','e','i','o','u','A','E','I','O','U'} s =list(s) left, right =0,len(s)-1while left < right:while left < right and s[left]notin vowels: left +=1while left < right and s[right]notin vowels: right -=1if s[left]in vowels and s[right]in vowels: s[left], s[right]= s[right], s[left] left +=1 right -=1else:breakreturn''.join(s)