Anti Vowel


#1



https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096#

Hey, so I'm not sure why my != operator isn't preventing vowels from being appended to my no_vowel list. My for statement iterates through my argument, but the != doesn't seem to do anything. Does this have to do with comparing integers to a string?


Replace this line with your code. 
def anti_vowel(text):
    no_vowel = []
    for i in range(len(text)):
        if i != "aeiouAEIOU":
            no_vowel.append(text[i])
    return "".join(no_vowel)
print anti_vowel("Cat!")


#2

here:

for i in range(len(text)):

Why use range()? this will give us numbers, which we can use as indexes, but this only complicate matters. Just get rid of range and len

now that i actually contains values from our list, a single letter can't equal a whole string of vowels.

we can use in to determine if the letter is in the vowel string. then we can use not to ensure the letters are not in vowel string


#3

Hey, thanks! I think the problem stemmed from me making my no_vowel variable = a list and not a string. Lists cannot be appended with a string, which is why i used the range(len) function to split up my argument into integers. And everything went off the rails from there lol.


#4

you can perfectly fine append strings to lists, its no problem:

aList = []
aList.append("see?")

If you need more help, post an updated version of your code


#5

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