"string indices must be integers, not str" error.

I don't understand what I am doing wrong

def anti_vowel(text):
    word = []
    for l in text:
        if l not in 'aeiouAEIOU':
    return "".join(word)


The l from for l in text: is a single letter from text. So, text[l] is the equivalent of doing something like:

list = ["hello", "hi", "hey"]

You already have access to the current letter with l, so all you need to do is to append that to word.

Hopefully that helps you out!


That did help. Thanks :slight_smile:


bro you need to use text[l] instead of l

 if text[l] not in 'aeiouAEIOU':

l is just a position to address the element text[l] has to be used


That is incorrect. The for loop is already checking each letter in the string, so all he needs is to use l.


Please do not post complete code as an answer, it takes deprives people of actually learning why the code works.


how is this incorrect can you please elaborate.
my code worked only when i used text[l] not just l
basically l is just a position to address according to me
for eg
here l will just be a number and the code will be checked for having 01234 in the vowels not the words


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