given a sentence write a program rotate all the words left so that every word starts with a vowel.
note: if there is no vowel in the word do not rotate it.
sample input:
I saw a DRAGON flying in the sky
sample output:
I aws a AGONDR ingfly in eth sky
def IsVowel(char):
return (char.lower() in ['a', 'e', 'i', 'o', 'u'])
def RotateLeft(word):
return word[1:] + word[0]
def Rotate(word):
if IsVowel(word[0]):
return word
for i in range(1, len(word)):
word = RotateLeft(word)
if IsVowel(word[0]):
return word
return RotateLeft(word)
result = ''
for w in input().split():
result += Rotate(w) + ' '
result = result[:-1]
print(result)
Comments
Leave a comment