Hey guys! Here is my code, is there any problem with this ? I dont understand what wrong with the else statement.Did i put it in wrong place?

When I delete the else statement then the result is:
Your function fails on anti_vowel("Hey look Words!"). It returns "Hey lk Wrds!" when it should return "Hy lk Wrds!".

Somebody help me please!!

Replace this line with your code.


That link does not provide a link to your code but instead to ours. So you still need to post your code the link just provides a reference to the exercise you are on.


def anti_vowel(text):
new_text = ""
for i in text:
if i in "aeiouAEIOU":
new_text = text.replace(i,"")
return new_text
return text
Okay!! I posted my code!


In the line "new_text = text.replace(i, "")" you just need text instead of new_text. Hope this helped :slight_smile:


Perhaps you could make a new list at the top before your defined function like...

vowels = ["A", "a", "E", "e", etc...]

Then try checking to see " IF i IN vowels" then return 'new_text = new_text + ""'.
That would just replace the vowel with nothing.
Then you could do an "else" after the "if" that would just add the character (your variable "i") in (since the rest aren't vowels).

It's pretty much the same idea as yours, but just puts that "aeiouAEIOU" into a list on top.


Thank you! I fixed it.


this is also works:

def anti_vowel(text):
empty_text = ""

for n in text:
    if n == "a" or n== "e" or n == "i" or n== "o" or n =="u":
    elif n == "A" or n== "E" or n == "I" or n== "O" or n =="U":
        empty_text += n
return empty_text

print anti_vowel("Hey You!")


Hi, here is my version:

def anti_vowel(text):
    for t in text:
        for v in vowels:
            if v==t.lower():
        if assist_counter!=1:
    return unvoweled
print anti_vowel("It's a test of anti-voweling!")


Hi, I'm using this code on my program. it's almost similar like @roaster97 did. But I do the reverse

def anti_vowel(text):

for n in text:
    if n not in "aeiouAEIOU":
        new_text += n;
return new_text;

print anti_vowel("Hello world");

it worked on mine


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