8/15, anti_vowel problems--please help!


#1

This is my code for 8/15, please help--I've been working on this for 3 hours now . . .

def anti_vowel(text):
anti_vowel == text
vowel == ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
for vowel in text:
del vowel
else:
print text

This is what it tells me:
Oops, try again.
Did you create a function called anti_vowel? Your code threw a "local variable 'vowel' referenced before assignment" error.


#2

the problem is you used a comparator to assign it would be like asking what is b/a when you only know a


#3

I'm not sure what a "comparator" is--could you explain a bit more what you mean?


#4

I think This answers your comparator question. By using == you're equating vowel to ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"] instead of using = to create a new variable. Here's my take on your code:

def anti_vowel(text):
vowel = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
for i in range(0, len(vowel)):
    text = text.replace(vowel[i], "")
return text

Hope this helps


#5

This was really cool, thanks. But I just wondered what the third line of your code meant? I'm sort of confused on that.

for i in range(0, len(vowel)):

Why is this needed? Thanks in advance!


#6

It covers the entire length of the variable vowel. since lists are ordered from index 0 putting the range from 0 to the length of the vowel list (len(vowel)) covers everything in the list so that whatever is in the list is replaced whenever it appears in a string.
Glad to help getting through these courses can be challenging at times.