Answer to Question #188631 in Python for phani

Question #188631
Vowel Sound

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.

Input

The input will be a single line containing a string.

Output

The output should be a single line containing the modified sentence with rotated words.

Explanation

For example, if the given string is "I saw a DRAGON flying in the sky", rotating each word towards left in this way "I aws a AGONDR and ingfly in eth sky", makes every word start with a vowel letter. The word "sky" is not rotated as it does not have any vowel in it. The words "I", "a", "and", "in" are not rotated as they already start with a vowel.

Sample Input 
I saw a DRAGON flying in the sky
Sample Output 
I aws a AGONDR ingfly in eth sky


1
Expert's answer
2021-05-03T20:00:15-0400
def vowels_rotate(arg):
    vowels =['a', 'e', 'i', 'o', 'u']
    for indx, letter in enumerate(arg):
        if letter.lower() in vowels:
            return arg[indx:]+arg[:indx]
    return arg 


user_str = input("Enter your string: ")
words = user_str.split()
for i in range(len(words)):
    words[i] = vowels_rotate(words[i])
print(*words,sep="  ")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS