Anti_wovel my O and o doesn't get removed


I've almost completed this exercise but I get a slight error. When I submit the code this is the error message;
"Your function fails on antivowel("Hey look Words!"). It returns "Hy lok Words!" when it should return "Hy lk Wrds!"._"
As you can see, my functions dosen't seem to remove lowercase or uppercase letter 'o' and I don't know what to do.

Below is my code:

def anti_vowel(text):
    text_list = list(text)
    for c in "aeiouAEIOU":
        except ValueError:
            pass  # do nothing!
    result = ''.join(text_list)
    return result


You should try making a list of vowels:

vowels = ["A", "a", "E", "e", "I", "i", "O", "o", "U", "u"]

Then a list called anti

anti = []

then work on a look and a if/else statement


Your code:

for c in "aeiouAEIOU":

only executes one time, you need to loop it for all of text_list

What your code is doing is finding ONLY the first vowel and removing that


And I don't believe I've seen the "try" command before. What is that?


This throws an error:

Oops, try again.
Your function fails on anti_vowel("Hey look Words!"). It returns

"['H', 'y', ' ', 'l', 'k', ' ', 'W', 'r', 'd', 's', '!']" when it should
return "Hy lk Wrds!".

It doesn't join words.


return "".join(anti)

will solve the problem


True, that's when I am not creating a list but empty string. Thanks.


Why isn't it looping. I have used that syntax before like this:

for c in "test":
    print c

That works just fine...


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