Anti-Vowel, nested loop problem?


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


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!


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