8/15: Anti_vowel - works in terminal but not codecademy


Hi all,

I need some help. My code worked in my terminal but when i tried to run it on codecademy, it just won't work...Can someone help me understand why this is the case? I have had a few of these and it's making me really frustrated...

a = list()
def anti_vowel(text):
for letter in text:
if text[index] in "aeiouAEIOU":
index = index + 1
print ''.join(a)


Hi, I'll try to help:

First the "a = list()" should be defined inside of the function, but when i did that for some reason the output string was always adding "bcd" in front of the string without the vowels, which made me think that the error was due to the "a = list()", don't know the exact reason.

So i tried to replace the "a = list()" with "word = []" and the problem disappeared. And the code is like this:

Help with anti_vowel code

Here is what I did, I felt this was simplistic

def anti_vowel(text):
    for char in "AEIOUaeiou":
        text = text.replace(char, '')
    return text


@slobodank you can create a list either by doing

my_list1= list()
my_list2 = []

#both work fine and you can perform list operations on them



thanks for the code...it's legit code :grin:


def anti_vowel(text):
want = []
dwant = []
for i in range(len(text)):
if text[i] == "a" or text[i]== "e" or text[i]== "i" or text[i]== "o" or text[i]== "u" or text[i] == "A" or text[i]== "E" or text[i]== "I" or text[i]== "O" or text[i]== "U":
print "".join(want)

I have the same problem with getting it correct on the terminal but receiving an error message from codeacademy! Help!?