Anti_vowel problem


#1



Hi everyone,
I'm stuck with the anti_vowel exercise on 15. Practice makes perfect.


https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096


Oops, try again. Does your anti_vowel function take exactly one argument (a string)? Your code threw a "'str' object is not callable" error.


def anti_vowel(text):
    new_word = ""
    
    for i in range(len(text)):
        if text(i) == "a" or text(i) == "A":
            new_word += ""
        elif text(i) == "e" or text(i) == "E":
            new_word += ""
        elif text(i) == "i" or text(i) == "I":
            new_word += ""
        elif text(i) == "o" or text(i) == "O":
            new_word += ""
        elif text(i) == "u" or text(i) == "U":
            new_word += ""
        else:
            new_word += text(i)
    
    return new_word

Not really sure where I'm going wrong to be honest


#2

i contains indexes of your text string. to access items of string with indexes, use square brackets, not parentheses (parentheses are function calls)


#3

Wow - I feel like such an idiot now haha.

Thanks for the help!


#4

issue resolved?

Knowing that this are function calls, it also explains the error message:

threw a "'str' object is not callable" error.

text is a string, and its not callable (can't call a function), maybe useful to know for next time


#5

Yes thank you - the code works now and I also understand the error message :slight_smile: once again thanks for your help!


#6