__get_item__ error


def anti_vowel (text):
text_to_return=""
for i in range(len[text]):
if text[i]==“aeiouAEIOU”:
print text[i]
else:
text_to_return+=text[i]
i+=1
return text_to_return

print anti_vowel(“bat”)


This code is returning the following error. I am not able to understand. If some one can help, it would be great.

Traceback (most recent call last):
File “python”, line 11, in
File “python”, line 3, in anti_vowel
TypeError: ‘builtin_function_or_method’ object has no attribute ‘getitem

Got it…

for i in range(len[text]):

It should be:

for i in range(len(text)):

2 Likes