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

Been stuck on this one for days. Any suggestions on which units I can go back and review to help me wrap my head around this? Guidance appreciated.

vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']

def anti_vowel(text):
    n = ''
    for letters in text:
        if letters not in vowels:
            n += letters
        result = n
        return result


a function ends the moment a return keyword is reached

Even when the return keyword is reached in a loop, the function needs to end, so the loop will break

so, your loop breaks in its first iteration

place return outside the loop so your whole can run to reverse the string


Strings are immutable on like lists so you cant add characters directly except via concatenation...Try using the .replace("a", "replacement here")...Or just go through the piece. It worked
def anti_vowel(text):
for v in text:
if v in "aeiouAEIOU":
text = text.replace(v,"")
print text
text = text.replace(v,v)
print text
return text


very true stetim94. return must be outside the loop


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