Anti_vowel no mistake,but showin mistake


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

But my code is working. It shows exactly what was asked for "Hy lk Wrds!" I also checked it on other python shell and it is okay there.

def anti_vowel(text):
    word = ""
    for char in text:
        if char != 'A' and char != 'a' and char != 'O' and char != 'o' and char != 'U' and char != 'u' and char != 'E' and char != 'e' and char != 'i' and char != 'I':
            word += char
    print word
print anti_vowel('"Hey look Words!"')


That is because there is no return statement. Instead of print, return word.

Refactoring tip:

The if statement can be greatly reduced by using a single string and the not in operators.


Instead of print word, use return word to return word to the function. Also remove the print when you call the function, the exercise doesn't require that statement.


Thank you.
Works now.


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