Why isn't my code functioning correctly?!


#1



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


The code will not filter the vowels from the input.


It's supposed to filter all vowels out.


def anti_vowel(text): 
    vowels = ["aeiouAEIOU"]
    final = ""
    for letter in text: 
        if letter not in vowels: 
            final = final + letter
    return final
print anti_vowel("Hi")


The last line is just for testing.


#2

The in operator is not recursive, meaning it doesn't drill into elements. It sees this element as a string that does not match any single letter. Try using just the string without the brackets.

Or,

if letter not in vowel[0]:

#3

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