AEIOU Emo

Hey guys!

To any who may have seen my last post in the Corner bar, it was about a database I was working on, which I have gotten to work, thanks to @mtf and his suggestion to use .lower(). I strongly suggest asking him or any of the other very accomplished moderators on codeacademy discuss for questions.

However, this is for another project I have been working on. A few days ago, a friend approached me with a challenge to write a program to take an input from the user and change all the vowels to the word ‘emo’. I wrote this program, and it ran successfully, except for the fact that it changed only one of the vowels of the word. My code is the following, if anyone can take a look and let me know the issue, that would be great. Thanks! :slight_smile:


Code:

vowels = ['a','e','i','o','u']

while True:
    message = input("MESSAGE: ")
    if not message.lower() == "break":
        for x in message:
            for y in vowels:
                if x == y:
                    new = message.replace(x,'emo')
        print(new)
    else:
        break

Thanks!

Do you mean something like this?

import re
def emo(s):
    return re.sub("[aeiouy]", "emo", s)

print(emo("banana"))
print(emo("python"))
print(emo("bureaucracy"))
print(emo("emotion"))

Output:

bemonemonemo
pemothemon
bemoremoemoemocremocemo
emomemotemoemon
2 Likes

Thanks @appylpye

Worked like a charm. Much appreciated for the fast and successful response.