Anti-Vowel


#1



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


Oops, try again. Does your anti_vowel function take exactly one argument (a string)? Your code threw a "string indices must be integers, not str" error.


def anti_vowel(text):
    for i in text:
        if text[i] == "A" or text[i] == "a":
            text.pop(i)
        elif text[i] == "E" or text[i] == "e":
            text.pop(i)
        elif text[i] == "I" or text[i] == "i":
            text.pop(i)
        elif text[i] == "O" or text[i] == "o":
            text.pop(i)
        elif text[i] == "U" or text[i] == "u":
            text.pop(i)
    return text


#2

Try using just a lop and a if/else, not all of your elif statements.
first make a list of vowels:

 vowels = ["A", "a", "E", "e", "I", "i", "O", "o", "U", "u"]

Then a empty list of anti

anti = []

Your loop should look something like this:

for i in text:
        if i in vowels:
            pass
        else:
            anti.append(i)

Then return the answer.


#3

Thanks for a quick response !!


#4

Thanks. can you mark my answer as the solution? it's by the like button


#5

Not the like button, it looks like a check mark


#6

3 posts were split to a new topic: Anti-vowel


#7