Anti vowel = Stack overflow answer didn't work - Why not?


#1

Hi. this answer didn't work. Anyone know why not and what needs to be fixed? I'm stuck and I don't just want to copy someone else's answer to get through as I'm not learning anything.

def del_vowel(text):

for i in text:
    if i.lower() in ['a','e','i','o','u']:
        text.replace(i,"")
return text

#2

Method replace doesn't change the original string. It returns copy of the string with all occurrences of first parameter replaced by second parameter.

This code:

text.replace(i,"")

doesn't make any change to the text string. You have to capture result of the method:

text = text.replace(i,"")