Anti_vowel


#1


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

It does not work


Replace this line with your code. 
def anti_vowel(text):
    vowels = "aeiouAEIOU"
    text = text.lower()
    for x in text:
        if x in vowels:
            line = text.replace(x,"")
        else:
            line = text
    print line


#2

Hi @bruceyboy,

When I run your code, I get a message that it returns "None". This is what you will get if you have not used a return statement. What would you like your function to return?

We should also have a closer look at the logic that is going on here:

    for x in text:
        if x in vowels:
            line = text.replace(x,"")
        else:
            line = text

Let's use "The quick brown fox jumps over the lazy dog." as text and just walk slowly through your code. See if you can spot the logic problem.

Loop 1:
- x is t
- t is not in vowels
- line = text makes line = "The quick brown fox jumps over the lazy dog."

Loop 2:
- x is h
- h is not in vowels
- line = text makes line = "The quick brown fox jumps over the lazy dog." (again)

Loop 3:
- x is e
- e is in vowels
- - line = text.replace(x,"") makes line = "Th quick brown fox jumps ovr th lazy dog."

Loop 4:
- x is (a space)
- (a space) is not in vowels
- line = text makes line = "The quick brown fox jumps over the lazy dog." (back to this again, darn)

You might want to think about what you really want to do in your if statement. Think about it in English first, put it into steps just using words.

Give it another go and come back and tell us how you got on with it.


#4

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