8. anti-vowel


#1



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


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


vowels = ["a", "e", "i", "o", "u"]

def anti_vowel(text):
    new_w = ""
    index = 0
    for letter in text:
        if letter.lower() in 'aeiou':
            index = index + 1
            new_w = new_w + letter
    return new_w

print(anti_vowel("abc"))


#2

Your return value is all the vowels in the phrase when it should be all the consonants.

No used, not needed.

What happens if you use not in?


#4

Still does not work

vowels = ["a", "e", "i", "o", "u"]

def anti_vowel(text):
new_w = ""
for letter in text:
if letter.lower() not in 'aeiou':
index = index + 1
new_w = new_w + letter
return new_w

print(anti_vowel("abc"))

Oops, try again. Did you create a function called anti_vowel? Your code threw a "local variable 'index' referenced before assignment" error.


#5

That line is also not doing anything, and is where the error is raised. It too may be removed.


#6

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