Anti-vowel


#1


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


#2

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


#3

Fixed it now. Thank you!


#4

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