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


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
            n += char
            return n


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.....


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.


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