Anti vowel


Your function fails on anti_vowel("Hey look Words!"). It returns "Hey lk Wrds!" when it should return "Hy lk Wrds!".

def anti_vowel(text):
    for i in text:
        if i in "aeiouAEIOU":
    return new


you are replacing from text variable and storing the result in new variable

this means, textwill not be modified, so the last vowel replace, o, is the only this sticks, we can see this really nicely if we add some print statements:

def anti_vowel(text):
    for i in text:
        if i in "aeiouAEIOU":
            print new
    return new

print anti_vowel("a best this do thus")


I am not getting how to move forward. pls help


But you see what is wrong, right? Only the last change replace action stands

So you want to store the string in the same variable as you are replacing from, so that after removing the a the string you are replacing from has no a, so that in the end, all vowels are removed


i understand what you are saying.
but what i didnt understand is how to write the code.
i repalced the vowel but how to updat the original "text" variable simultaneously?
or should i store the removed vowels in a list and the remove those (something like that)?


that is the easy part? We can simply store the result of the replace action in text variable rather then new variable


Problem solved btw..thank you so much


Its not a time waste, you learned valuable things :slight_smile:

good to hear problem is solved, you're welcome :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.