📢 𝗗𝗮𝘁𝗮𝗘𝗻𝗴𝗶𝗻𝗲𝗲𝗿𝗶𝗻𝗴--𝗣𝘆𝘁𝗵𝗼𝗻
🚩𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻-1
🚀 '''
𝗥𝗲𝘃𝗲𝗿𝘀𝗲 𝘃𝗼𝘄𝗲𝗹𝘀 𝗶𝗻 𝗮 𝗴𝗶𝘃𝗲𝗻 𝘀𝘁𝗿𝗶𝗻𝗴
Input= "hello world".
output= "holeo wlrld".
'''
----------------------------------------------------------------------------
📌𝗔𝗽𝗽𝗿𝗼𝗮𝗰𝗵 𝟭
def isVowel(c):
return c in 'aeiouAEIOU'
def reverseVowel(s):
s = list(s) # Convert string to list
i = 0
j = len(s) - 1
while i < j:
if not isVowel(s[i]):
i += 1
continue
if not isVowel(s[j]):
j -= 1
continue
s[i], s[j] = s[j], s[i]
i += 1
j -= 1
return ''.join(s) # Convert list back to string
No comments:
Post a Comment