15. Anti-vowel



I get the error message; "'str' object has no attribute 'remove'" error. I don't know what the means or what I am missing here. Any help is appreciated.

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


string is of immutable data type.. so remove() method does not work for it.

remove() works for list.. so try converting string to list then when you remove all vowels ,you can convert it back to string ?


The error is that .remove is a method that works for lists only , so you have to convert the input to a list & then convert that list to a string again


def anti_vowel(text):
    vowels = ['a','e','i','o','u','A','E','I','O','U']
    l = list(text)
    for v in l:
        if v in vowels:

I hope you understand the error , & NOW you have to complete this code in order to make your code Functioning correctly


Thanks to both of you, that was helpful. Here is my completed code. Would be interested in your input if you would have gone about it differently than what I have below.

def anti_vowel(text):
    vowels = "aeiouAEIOU"
    vlist = list(vowels)
    tlist = list(text)
    for t in text:
        if t in vlist:
    return ''.join(tlist)


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