Anti_vowel


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096#


"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':
            word.append(text[l])
    return "".join(word)


#2

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"]
list["x"]

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!


#3

That did help. Thanks :slight_smile:


#4

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


#5

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


#7

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


#8

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
HELLO
01234
here l will just be a number and the code will be checked for having 01234 in the vowels not the words


#9

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