Anti_vowel Question


#1




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


#2

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

def anti_vowel(text1):
    vowels="aeouiAEOUI"
    text2=""
    for i in text1:
        if i in vowels:
            text2=text2
        else:
            text2+=i
    return text2
text3=raw_input("Text:")
anti_vowel(text3)

#4

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':


#5

why does text2 = text2


#6

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.


#7

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