'str' object does not support item assignment


I don't understand what's wrong with this.

def anti_vowels(text):
    vowels = "aeiouAEIOU"
    for i in range(0,len(text)):
        for text[i] in vowels:
            text[i] = ""
    return Text

print anti_vowels("helloworld")


well, you made so many choices that are making your code harder and harder there are simpler ways to go trough this ;
first there is no need to combine two for loop because you need just to iterate over the variable vowels and check if one of the letters in it exist in you text ,the input of your function,
besides you should be careful with the words you type like this one you don't have anything called Text
to sum up, it's a good idea to familiarize yourself with the code bellow it's really simple then try another time with your own ideas :wink: :

def anti_vowel(text):
    for x in vowels:
    return text 
    print text
print anti_vowel('adnan')


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