[anti_vowel]what's wrong with my code


#1


I don't khow why it always reminds me that i can't remove the 'o' in the word 'words'.and the error message is :
Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "None" when it should return "Hy lk Wrds!".
I have tried many times and whatever the last word is ,like 'look' or any other ,it has the problem.

i don't know the specific reason what happened ,but it seems the function remove() make trouble,what should i do? :worried:


def anti_vowel(text):
    
    list_text=list(text)
    for item in list_text:
        if item in 'aeiouAEIOU':    
            list_text.remove(item)
    print ''.join(list_text)
anti_vowel('hey look words!')


#2

so first you have to replace print with return
second you have to clone your first list and remove vowel from the second list not the first

def anti_vowel(text):
    list_text=list(text)
    lista=list_text[:]
    for item in list_text:
        if item in 'aeiouAEIOU':    
            lista.remove(item)
    return ''.join(lista)
anti_vowel('hey look words!')

#3

well, it works.Thank you! :blush: