Anti_vowel - removing whole thing?


#1



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


My code gives the error: Your function fails on anti_vowel("Hey look Words!"). It returns " ey look Words!" when it should return "Hy lk Wrds!".
I have no idea how it removed the "H", that was not in my code at all.
I realise there is something wrong with my if statement, but i can't work out what, please help me realise my mistake.
Thanks in advance :relaxed:


def anti_vowel(text):
    for letter in text:
        if letter == "a" or "A" or "e" or"E" or "i" or "I" or "o" or           "O" or "u" or "U":
            text = text.replace(letter, " ")
            return text
        else:
            return text


#2

You are somewhat overthinking this. Try following this template:

def FUNCTION(PARAMETER):
    for INDIVIDUAL_ITEM in str(PARAMETER):
        if INDIVIDUAL_ITEM in "aeiouAEIOU":
            text = text.replace(INDIVIDUAL_ITEM, "")
    return PARAMETER

If you have any questions on how or why this works, please, just ask.


#3

Thank you that worked :relaxed:


#4

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