Python 8.9 Practice Makes Perfect Question


#1


This is the 8th problem "anti_vowel" in "8. Loop, Practice Makes Perfect". The following is my code:

def anti_vowel(text):
....n=len(text)
....vowel="aeiouAEIOU"
....for i in range(0,n):
........for j in range(0,10):
............if text[i]==vowel[j]:
................text[i]=" "
....return text


It says "Does your anti_vowel function take exactly one argument (a string)? Your code threw a "'str' object does not support item assignment" error." But I don't know what does this mean?
What is the problem with this code?
Thank you!


Replace this line with your code.


#2

here:

text[i]=" "

text is a string. what you do here (item assignment) is for lists, it doesn't work for strings. (strings are immutable)


#3

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