Anti_vowel Question


It passed the test but I wonder there must be some ways to simplify my code. I found it's too redundant. Thanks!


Hi. I have just passed this exercise with different codes that are below.

def anti_vowel(text1):
    for i in text1:
        if i in vowels:
    return text2


Check the hint, sometimes they are useful, although you could make it without.
You can use in to compare your characters
if char in 'aeiouAEIOU':


why does text2 = text2


Hi finsteammascot,

As you can see, at the beginning, variable text2 is an empty string and variable vowels includes vowels. Then in order to find the vowels of text1, a for loop was determined. For item in text1, if item is in vowels; text2=text2. This means; if the item belongs to both vowels and text1 variables, don't change text2. But in else case, the codes add text1's consonant items to text2 then returns the new text2 variable not text1 variable.


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