8.15 Simpler Way to do This?


This code here worked just fine:

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

I was just curious though, is there an easier/cleaner way to do this?



from re import sub
def anti_vowel(text):
    return sub('[aeiouAEIOU]', '', text)


def anti_vowel(text):
    return ''.join((letter for letter in text if letter not in 'aeiouAEIOU'))

Easy enough.


You are a wizard, my friend.


it"s simple cool..but i dont understand what that does...could you please explain me that stuff??