The message says "Did you create a function called anti_vowel? Your code threw a "global name 'a' is not defined" error." I don't understand why this message shows up, since I have created the function. Can anyone help me out here?

def anti_vowel(text):
    for i in range (0,length):
        for x in vowels:
            if x==textn[i]:
        return text


I'm no professional, but I'd say you have to use ['a', 'e', ...] when you define vowels


@tudoumimosa your list of vowels should have quotation marks around each letter because each of them is supposed to be a string. If your code doesn't work after that, then try mine:

def anti_vowel(text):
    word = '' 
    for letter in text:
        if not (letter in 'aeiouAEIOU'):
            word += letter
    return word


Your code is much better. Thank you!


Welcome! Glad to help!:slight_smile:


could you please let me know why this code does not work for all the cases


Want a concise method?

def anti_vowel(text):
    word = filter(lambda i: i not in "aeiouAEIOU", text)
    return word

You'll understand when you get to the "Advanced Topics in Python" section


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