Anti vowel


#1

i have also trouble i don't want to begin a new topic i think it's a hard exercise all of it

def anti_vowel(text):
    # transform text to lower_text
    lower_text = text.lower()
    lower_text = list(lower_text)
    for char in lower_text:
        if char == "a" or char == "e":
            lower_text.remove(char)
        return lower_text
        print lower_text
        elif char == "u" or char == "i":
            lower_text.remove(char)
        return lower_text
        print lower_text
        elif char == "o":
            lower_text.remove(char)
        return lower_text
        else:
            return text
anti_vowel("qwertyUUUU")

Anti_vowel
#2

actually, we prefer you begin a new topic.

Did you read the topic i replied to? i didn't recommend the remove() approach.

i also said (in that topic) that a function ends the moment a return keyword is reached, so the only time you want to have a return keyword, is after the loop (when you are done removing vowels)

go with the opposite approach, append constants to new list/string, its much easier


#3

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