Anti-Vowel


#1
def anti_vowel(text):
    n = []
    text_n = ""
    for char in text:
        n.append(char)
    print n
        
    for item in n:   
        if item in "aeiouAEIOU":
            n.remove(item)
            print n
    
    for item in n:
        text_n = text_n + item
    print text_n    
        
    return text_n
    

anti_vowel("Hey Look Word!")  ----- print--"Hy Lk Word!"

I don't know what is happening but when there are 3 or more same vowel in the string, this function will always leave the last vowel in the string....

for example:

anti_vowel("Hey Laak Ward!)  ---- print--"Hy Lk Ward!"
anti_vowel("Hey Look Ward!)  ------will be ok-----print-- "Hy Lk Wrd!)

Can anybody help me with this please? Thank you!


#2

What error messages are you receiving (SCT and/or compiler)?


#3

There is no error message.I just cannot get the result as the mission says.The code seems all fine.


#4

I answered a similar question here, so I will leave it you as a challenge to relate that problem to yours. I can surely tell you that both of you had the same problem, let's see if you can find it :smiley:


#6

Idk if you have already figured this out by now, but anyways; you mistake is in the second for-loop, it should be expressed as part as the first for-loop. its just a problem of indentation. I had the same issue.


#8

A post was split to a new topic: Function returns "Hy lk Words!"