Anit vowel


#1



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


I am getting: Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "Hy look Words!" when it should return "Hy lk Wrds!".


I am getting "Wht re you doing" for a result instead of removing all the vowels. It will only remove the first vowel. I also tried c in "aeiouAEIOU" but again it only takes out the a.


def anti_vowel(text):
    for c in text:
        if c in "a":
            return text.replace(c, "") 
        elif c in "e":
            return text.replace(c, "")
        elif c in "i":
             return text.replace(c, "")
        elif c in "o":
             return text.replace(c, "")
        elif c in "u":
             return text.replace(c, "")
print anti_vowel("What are you doing")


#2

You don't need to use .replace. Start by building a new string, I will call it "answer" and set it equal to ' ' (an empty string) before your for loop.

Next, whenever c does NOT appear in "aeiouAEIOU" then add it to answer:

(answer += c)


#3

?

Says it all. What are vowels but letters? And letters form strings. "aeiou".


#4

Maybe you can elaborate a little:
obviously, you can use != for doesn't equal but how would you code "does not appear in?"

this is what I have so far

def anti_vowel (text):
    string = ""
    for c in text:
        if not c in "aeiouAEIOU":
            return string += c

but I am throwing an invalid syntax error at "answer += c"


#5

not c is False.

c not in will be True if c is not found in text.


#6

Much appreciated. That was really helpful!


#8

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