Help! anti_vowel


Error message:
Oops, try again. Did you create a function called anti_vowel? Your code threw a "global name 'a' is not defined" error.

Help me work out where ive gone wrong, im trying to check if my letters in my list are found in the text.

Replace this line with your code. 

def anti_vowel(text):
    vowels = [a, e, i, o, u, A, E, I, O, U]
    for n in vowels:
        if vowels[n] in text:
            n = str(vowels[n])
            text = text.remove(n)
        return text



vowels = [a, e, i, o, u, A, E, I, O, U]

everything in the lists are variables, are you sure you want this to be variables?


I think i have improved it but i am still struggling:

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


you are close. A function ends the moment a return keyword is reached, this is currently happening in the first iteration of your loop, you might want to place return outside the for loop


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