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

def anti_vowel(text):
    for l in text:
        if l in "aeiouAEIOU":
            return "".join(text)
            return text




This makes text an empty list, did you mean



If a return statement is reached inside of a for loop the loop exits, so you will have to move the return statement outside of the loop.

Also iterating over a list your are changing can have unexpected consequences. It's better to iterate over one list and removing items from a copy of it or alternatively, iterate over the text string and append all none-vowels to an empty list.


omg, it totally worked! Thanks!


I have tried this:
def anti_vowel(text):
text = list(text)
texts = text
answer = ""
for l in texts:
if l in "aeiouAEIOU":

for i in text:
    answer += i
return answer

anti_vowel("Hey look Words!")

But it dosesn't work. What's wrong?


You are looping over the same list you are removing items from. I think that's the problem. What error do you get?


It says onIy only returns Hy Lk Words! Notice the O in words


Try changing this

texts = text


texts = text[:]

I think otherwise texts just points to the text variable instead of beeing a new copy of it.


def anti_vowel(text):
    vowels = ["a","A","e","E","i","I","o","O","u","U"]
    result = text
    for i in vowels:
        if i in result:
            result = result.replace(i,"")
    return result

print anti_vowel("Who let the dogs out?")


Hey guys,
this is my code, can't figure out the issue.

def anti_vowel(text):
----for c in text:
--------if c not in "aeiouAEIOU":
----------- print c,
----return c


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