Indicating a variable inside a function built into python


I'm stuck on 15.8 : anti_vowel
It gave me a "list.remove(x): x not in list" error when I submitted my code. As far as I understand this is because in the line a.remove(t) it doesn't see t as a variable, but as the item in the list it should be looking for.
So my question is: is there a way to indicate to python that the t in a.remove(t) is a variable?
And if my code is otherwise flawed I would hope to figure it out myself as its the best way for me to learn

def anti_vowel(text):
    a = []
    for char in text:
    for item in a:
        if item in "aeiouAEIOU":
            t = a.index(item)
    a = ''.join(a)
    return a


Hi, @wyrmlord ,

The name, t, in your code is considered to be a variable. But to use the remove method on a list, you must pass an argument equivalent to the item to be removed, rather than pass the index of the item to be removed. The first item in the list that matches the argument is what gets removed.

However, your approach is buggy in that it alters the list at the same time that it iterates through it. This interferes with the iteration process.

Instead of appending all the characters in text to a, as you do in your first for loop, append only those characters that do not occur in "aeiouAEIOU". You only need one loop to do this.

Finally, you can call join from an empty str, with a as an argument, to produce the result.


@appylpye Ok so its seems I miss understood what should be input for .remove. And yeah I now realize how unnecessarily complex my code is, oh well, at least I learned something! Thanks!