8/15 anti_vowel - Question on elegance


Hey all,

Below is my solution for 8/15. I know it works, but I am left wondering about how good or bad of a solution this actually is. My solution depends on lists while the codecademy solution does not and I’m not sure if that’s something I should try and steer clear from or not.

Thanks in advance!

def anti_vowel(text):

    vowels = ['A', 'a', 'E', 'e', 'I', 'i', 'J', 'j', 'O', 'o', 'U', 'u']
    filtered = []

    for i in str(text):
        if i not in vowels:
    return "".join(filtered)


We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Donald Knuth

we waste more time discussing about this, then efficiency it will yield. Lists are mutable, so python might need to reserve a little more memory then a string (strings are immutable) or a tuple (immutable list).


Thanks for your reply! I know it may seem minor, but as I’m still in a very early stage of learning I might as well learn everything “right” the first time around and make clean code a good habit instead of having to relearn everything later!


Then its even more important to understand that small efficiencies are not worth the time.

If you want to do it right, start including comments:

def anti_vowel(text):
     # this function removes all vowels from a string


I will keep that in mind then! Thanks :slight_smile:


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