Anti-vowel


#1

help..what did i missing ?

def anti_vowel(text):
    vowels = ["a","i","u","e","o","A","I","U","E","O"]
    anti = []
    for i in text:
        if i in vowels:
            pass
        else:
            anti.append(i)
        return i
            
print anti_vowel("How do you do!")

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


Anti-Vowel
#2

Hi,

i am not an expert but you should try to modify the later part of your code by this ::
for i in text:
if i in vowels:
pass
else:
anti.append(i)
return anti


#3

a function ends the moment a return keyword is reached, which in your case happens in the first run of the loop, you might want to change the indent of return so the whole loop can run


#5

You're just missing a couple of things it looks like. The return is nested inside the for function which is why you're getting a result of just "H". You could also use a blank string instead of a blank list, as it's expecting a string as the result. Hope this helps!

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

print anti_vowel("How do you do!")


#7

RETURN ANTI_VOWEL should be on the same level as FOR I IN TEXT and after RETURN, write "" .JOIN(ANTI_VOWEL)


#8

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