Swap Continuous Vowels or Consonants



PYTHON:

def check(o,p):

    if o in 'aeiouAEIOU' and p in 'aeiouAEIOU':

        return 1

    if o not in 'aeiouAEIOU' and p not in 'aeiouAEIOU':

        return 1

s=list(input().strip())

t=''

for i in range(0,len(s)-1):

    if check(s[i],s[i+1]):

        s[i],s[i+1]=s[i+1],s[i]

print(*s,sep='')

Post a Comment

0 Comments