Anti-Vowel, nested loop problem?


#1



I am trying to remove all the vowels efficiently. The loops are supposed to check each letter in text against each letter in vowels. Thanks in advance.

The exercise


Your function fails on anti_vowel("Hey look Words!"). It returns
"HHHHHHHHHHeeeeeeeeeyyyyyyyyyy
llllllllllooooooooooooooooookkkkkkkkkk
WWWWWWWWWWooooooooorrrrrrrrrrddddddddddssssssssss!!!!!!!!!!" when it
should return "Hy lk Wrds!".


def anti_vowel(text):
    vowels = ["a","e","i","u","o","A","E","I","O","U"]
    words = ''
    if type(text) == str:
        for letter in text:
            for vowel in vowels:
                if letter != vowel:
                    words = words + letter
    return words


#2

I'm stuck on the same problem. you dont need to create a list called vowels including all vowels and you're creating too many loops! its just printing the text with multiple letters. Good luck and please share your answer when you get it!


#3

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