8/15 Anti-vowel - Why doesn't this work?


#1



It returns "H" when it should return "Hy lk Wrds!".


def anti_vowel(text):
    n = ""
    for char in text:
        if char in 'aeiouAEIOU':
            n += ""
            return n
        else:
            n += char
            return n


#2

@maldeos,
As soon as the return statement is excuted
you will EXIT the anti_vowel function......

Use this return statement as you ended the FOR-loop.....


#3

Nice use of in to parse the iterable. We can refactor to exclude an else if we only add valid letters.

    for ...
        if char not in 'aeiouAEIOU':
            n += char
    return n

This takes into account the point @leonhard.wettengmx.n was making, as well.


#4

Thanks very much for clearing my misconception on 'return'. :slightly_smiling: