Anti vowel,not working on the third 'o'


#1
def anti_vowel(text):
    text = list(text)
    for listchecker in text:
        for checker in 'aeiouAEIOU':
            if listchecker == checker:
                text.remove(listchecker)
    return ''.join(text)
    print text
anti_vowel('afsfsfsaf')`indent preformatted text by 4 spaces`

it eliminated the two 'o's in 'look' but not the third'o',why?
and why the print text in the function is not working after I call for the function


#2

Hi,

I think the problem is that you remove elements of the list you are iterating over. Try using two lists. On you use to loop over, and one list that you remove elements from.

Make a copy of text with text2 = text[:] otherwise your text and text2 will refer to the same list not to two different copies of the same list.

Also you print text after a return statement. If your function returns something it exits and won't execute code that comes after the return statement


#3

I wrote a more in depth answer here.