8. Anti Vowel (explain like i'm five)



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

This entire section has me stumped, but I thought I understood how to do this excersize. However, I can't figure out why it's NOT getting rid of the 'o' in 'Words!'

please help :cry: I'm so frusterated!

def anti_vowel(text):
    text_list = []
    for char in text:
    for x in text_list:
        if x == 'a' or x == 'e' or x == 'i' or x == 'o' or x == 'u':
    print "".join(text_list)
    return "".join(text_list)


.remove() is a difficult approach given index shifts will occur (causing problem with successive vowels)


What approach would you advise?


either make an empty list/string (your choice which is wiser, or which you are more comfortable with) and append/add constants to the list/string

or do you really want to make it work with remove()? (which i advise against)


OH, okay! so i was kind of on the right track, but not quite there.

I don't have any particular desire to use .remove(), it was just the only way I could think of to complete it. thank you! i'll be more wary of using remove() in the future


The behaviour of list.remove is to start from the beginning of the list and compare each element to the value you gave to remove.
When a value matches (==), that element is removed, and all the following elements are then moved one position forwards to fill the empty location caused by the removal

There's a lot there that isn't appropriate for getting rid of vowels, it's doing more undesirable things than desirable ones


thank you, now it makes sense why my code was skipping over the 'o' in words! I appreciate the feedback :slight_smile:


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