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

Replace this line with your code. 
def anti_vowel(text):
    string=" "
    n = len(text)
        if text[i] in "aeiouAEIOU":
            text[i]=" "
        i = i+1
        string = string + text[i]
    return string


This is the line that raised the error first. Changed it to,

x = text[i]

Then this line raises the same error...

text[i] = " "

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 7, in anti_vowel
TypeError: 'str' object does not support item assignment

Changing that line to,

x = ""

fixes the raised exceptions and outputs correctly. There is still one tiny detail remaining...

string =  " "

It should rightly be just an empty string, ""

With these three adjustments,

def anti_vowel(text):
    string  = ""
    i = 0
    n = len(text)
    while(i < n):
        if text[i] in "aeiouAEIOU":
            x = ""
            x = text[i]
        string += x
        i += 1
    return string

print anti_vowel('The rain in Spain falls mainly in the plains.')

# 'Th rn n Spn flls mnly n th plns.'


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