Anti_vowel


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096#


Hey ,
my code prints out "Hey lk wrds!" instead of "hy lk wrds!". I actually dont know what I did wrong. With spaces between the words, the code just removes "o" nothing else... Someone may got a hint?


def anti_vowel (text):
    vowel ="aeiouAEIOU"
    new =""
    for letter in text:
        if letter in vowel:
            new = text.replace(letter, "" )
    return new


#2

okay, here is a hint:

def anti_vowel (text):
    vowel ="aeiouAEIOU"
    new =""
    for letter in text:
        if letter in vowel:
            new = text.replace(letter, "" )
            print new
    return new

print anti_vowel("can then this for turn")

its mostly your code, i added a function call and a print statement, so you can see what your code does

because text doesn't change, only the last replace action in new persist

This is demonstrated nicely with a string like "can then this for turn" because you can first see the a being replace, then the e, then i and so on


#3

I solved it now in two different ways, the first way I figured out by my own. But your hint "because text doesn't change, only the last replace action in new persist" helped me to solve the problem with the code above.
chanced

new = text.replace(letter, "" )

to

text = text.replace(letter, "" )
new = text

Thanks a lot


#4

even without the hint, if you just ran the code, you would have seen this and be able to fix it :slight_smile:

well done :smiley:


#6