Anti_vowel, strange error


#1



I am getting this error : Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "bcdHy lk Wrds!" when it should return "Hy lk Wrds!".


I am really confused where the bcd comes from?


no_vowels=[]
def anti_vowel(text):
    for i in text:
        if i not in 'aeiouAEIOU':
            no_vowels.append(i)
    return ''.join(no_vowels)


#2

the exercise calls your function (not the whole script, just the function) multiply times. Because no_vowels declaration is outside your function, it might have leftovers from earlier calls, place the no_vowels declaration inside the function


#3

I am not able to get rid of all vowels, my output is 'Hy lk Words!'. Suggestions welcome

def anti_vowel(text):
t = []
for i in text:
t.append(i)
vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
for x in t:
if x in vowels:
t.remove(x)
return "".join(t)

print anti_vowel("Hey look Words!")


#4

do not use remove, it causes index shift and it super difficult to get it working with remove

append constants to a new list


#5

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