Anti_vowel


#1



https://www.codecademy.com/en/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!".


tho code doesn't remove all repeated vowels


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


#2

.remove() is a difficult approach to solve this problem. The problem is that you are looping over the same string as you are removing from

couple options:
1. choice a different approach (appending constants to a new list)
2. loop over text while removing from new
3. loop over new in reverse so the index shift doesn't occur.


#3

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