Anti_vowel


#1



def anti_vowel(text):
    for i in text:
        if i in "aeiouAEIOU":
           novowel= text.replace(i,"")
    return novowel

The error is:

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

Can someone please tell me where I am goin wrong?


#2

where do you create newvowel? It is new everytime, take a look (your code + print statements):

def anti_vowel(text):
    for i in text:
        if i in "aeiouAEIOU":
           novowel= text.replace(i,"")
           print novowel
    return novowel
print anti_vowel("that the this do us")

see? novowel is recreated every time, you might want to to create a copy of the text variable (and call it novowel) before you start your loop, so the variable isn't created everytime, but instead is being updated


#3

Since you are using string.replace() you do not need to iterate over text, only the list of vowels.

for i in 'aeiouAEIOU":
    text.replace(i, "")
return text

However, this is a more advanced approach that doesn't give us any practice with iteration, which you may wish to get more of. The right solution means nothing if we are not learning. Programming is not something we learn by rote, but by doing, repetitively with our sleeves rolled up until we are fully comfortable with the constructs and concepts. Don't cheat yourself of a solid learning experience.