Anti_Vowel function just returning ""



Here's the error message when I try to run the function: "
Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "" when it should return "Hy lk Wrds!"."

It should be returning "Hy Ik Wrds" but instead is returning "", but I can't for the life of me figure out the correct place for the return function.

def anti_vowel(text):
    vowels = "aeiouAEIOU"
    newText = ""
    for i in text:
        length = len(i)-1
        while length != 0:
            if i[length] not in vowels:
                newText = newText.append(i)
                length = length-1
        return newText


Add prints in your code and print out what it's doing as it's doing it. Observe what it does differently from what intend for it to do, and adjust the code where it behaves differently.
There are several things in there that do not behave like you expect them to, you'll just have to observe where they do something else and then find out more about that datatype/how to do that action.


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