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!".

Anyone know what im doing wrong?


def anti_vowel(text):
    lst = ['A','E','I','O','U','a','e','i','o','u']
    txt = list(text)
    for n in lst:
        for i in txt:
            if n == i:
                txt.remove(i)
    return ''.join(txt)


#2

Removing elements from a list that you're currently looping through affects what elements the loop visits - which you can verify by printing out the current character from within the loop


#3

ah thanks, managed to figure it out


#4

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