Can someone give me an idea why my for loop is not iterating and instead only returning the blank string?
Thank you.

def anti_vowel(text):
    new_string = ""
    for i in text:
        if i not in "aAeEiIoOuU":
            i += new_string
            return new_string

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


@jinxuandi ,

Where does this statement place the result of the concatenation? ...

i += new_string

Is it in new_string or is it in i?

Also check the indentation of your code, including that of the return statement.


Fixed it now. Thank you!


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