8.0 Anti_vowel


#1



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


Your function fails on anti_vowel("Hey look Words!"). It returns "['H']" when it should return "Hy lk Wrds!".


I thought adding a loop would solve the problem, but i already did it " for k in text" was my instruction but it said it was out of range, i dont know what im doing wrong, been looking for a similar exercise, hope a moderator can help me out.


def anti_vowel(text):
    #lenght= len(text)
    # text_list = list(text)
    counter=0
    no_vowels=[]
    for c in text:
      if text[counter] not in "AEIOUaeiou":
        no_vowels.append(text[counter])
        counter = counter+1
         
    return no_vowels


#2

why do you have a counter?

simply loop over text, you do this. Now each letter will be in c (your loop iterator), you can check if c variable is not in AEIOUaeiou, and then c to no_vowels list


#5

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