Anti-vowel


#1



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


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


Remove vowels from a string. I'm not sure why this isn't working. By the error message, it looks like I made a mistake on line 1, but I can't figure out what's wrong...


Replace this line with your code. 
def anti_vowel(text):
    new_string = ""
    for i in text:
        if i(text) in "aeiouAEIOU":
            continue
        else:
            new_string.append(i)
    return new_string


#2

here:

if i(text) in "aeiouAEIOU":

i contains characters from text string, so you can just check if i is in vowel string. doing i() makes a function call, strings are not function calls


#3

Hi. I thought that might be the case, so I ran it again:
def anti_vowel(text):
new_string = ""
for i in text:
if i in "aeiouAEIOU":
continue
else:
new_string.append(i)
return new_string

But I still have an error message: Oops, try again. Your code looks a bit off--it threw a "'str' object has no attribute 'append'" error. Check the Hint if you need help!


#4

.append() is a method append to a list, either make make new_string a list or use + to join strings


#5

Thank you very much for the help.


#6

Hey! I've been trying to figure out problem with this code but I'm stuck. I don't understand how it works differently for different inputs. Please help me resolve this. Thank you.

def anti_vowel(text):
anti=[]
final=""
for i in text:
anti.append(i)
print anti
for j in anti:
if j=='a' or j=='i' or j=='o' or j=='e' or j=='u' \
or j=='A' or j=='I' or j=='O' or j=='E' or j=='U':
anti.remove(j)
for i in anti:
final=final+i
print final
return final


#7

remove is a difficult approach to solve this problem

try the opposite aproach, append consonants to new list/string

you can add multiply function calls with different strings to see your function in action


#8

It worked. Thank you!


#9