Anti_Vowel


#1



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


Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "Hy lk Words!" when it should return "Hy lk Wrds!".


I don't get why it removes some but not the last vowel.


def anti_vowel(text):
    text = list(text)
    for i in text:
        if i in "aeiouAEIOU":
            text.remove(i)
    return ''.join(text)


#2

remove isn't the best method to solve this problem. Rather append constants to a new list

lets say we have: hey look words, it will find the first o of look. Which gets removed. but then the second o of look shifts to the index/position of your first o, while the for loop continues to the k (due to index shift), then find the o in words, and remove removes the first o it will find (the o from look which got skipped due to index shift


#3

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