8/15 - anti_vowel: Why 1 of my 2 solutions doesn't work?


I used 2 ways to solve the problem and ran them in Python GUI. Both of them can get the right result("Hy lk Wrds!").

However, on the online board, only the 2nd solution(codes after line 13) works. The 1st solution(codes before line 13) will get this error: Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "None" when it should return "Hy lk Wrds!".

Replace this line with your code.


Can you please give the link tot he exercise please ?


I think it's because you didn't return new in your first example, you printed it. A function will always look for a return command.


This is a solution I could gather from your code .

def anti_vowel(text):
vowels = ['a','A','e','E','i','I','o','O','u','U']
NoVowels = ""
for char in text:
    for vowel in vowels:
        if char == vowel:
        NoVowels += char

return NoVowels



def anti_vowel(text):

    word = []
    vowel_word = ""

    for i in text:

    for i in range(len(word)):
        for i in word:
            x = word.index(i)
            if i in "aeiouAEIOU":

    for i in word:
        vowel_word += "".join(i)

    return vowel_word   

print anti_vowel("Oii, Words")


There is a link at the very beginning, not for you?


I don't need a link anymore I figured it out look up ^


Thank you very much. However, I'm not to find another solution here. My question is what's wrong with my 1st solution, and why it can run correctly in Python GUI but not here.


did you not read my post? you used print and not return


OH...I missed your reply. SORRY. Thank you very much. But why the 1st works in Python GUI and coderpad.io?


Well in an IDE, they're not looking for anything specifically, so it's fine if you print it, but the lesson's correctness test is actually looking for you to return the string, so it does matter, but in GUI, it wouldn't really.
Hope I could help. :))


OOOHHH! I see. Thank you Kyleaw!


Oh Sorry XD Didn't see it XD


Thanks all the same!:clap:


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