Anti_vowel


#1

I'm pretty much stuck on anti_vowel. Can't figure it out...
I get this error: Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "h" when it should return "Hy lk Wrds!".
I can't really tell what the problem is, any help?

def anti_vowel(text):
    result = []
    vowels = ["a", "e", "i", "o", "u"]
    for i in text.lower():
        if i not in vowels:
            result.append(i)
            return "".join(result)

#2

Hi, @sam123bir ,

What relationship should the return statement have with the for loop?


#3

Gosh darnit. I see it now. I haven't got used to functions, I need to practice more. Thanks for the help. But now I get this error:
"Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "hy lk wrds!" when it should return "Hy lk Wrds!"."
Is there a way for me to return "text" back to how it originally was typed (with capital letters) so it returns the correct version of "result"?


#4

Yes, there is.

Consider what this loop header does, as it is now ...

for i in text.lower():

Specifically, what does the value of i become when the iteration encounters an uppercase letter?

Could you solve the problem by doing this instead?

for i in text:

... and then adapting the condition on this line to accommodate both lower- and uppercase?

if i not in vowels:

You have a couple of choices regarding how to do that.


#5

plus mind your Identation on your return


#6

Add Capital letter's in vowel then it will be accept.and make return statement inline with for loop


#9

what do you get when you run your code? First thing I see, your return should be outside your loop and its better to put your vowels in a str. e.g. vowels = "aeiouAEIOU". This way you don't have to use join() function.


#10