Anti_vowel


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/2?curriculum_id=4f89dab3d788890003000096#


Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "Hey look Words!" when it should return "Hy lk Wrds!".


Expected the vowels to be removed.


def anti_vowel(text):
    l = list(text)
    b = "AEIOUaeiou"
    for (n, i) in enumerate(l):
        for char in b:
            if i == char:
                l[n] = ''
            
        x = ''.join(l)
        return x


#2

Have you considered only keeping the characters that are not
appearing in "AEIOUaeiou"?

Try it out; it's a very short solution.

for char in text:
    if char not in b:
        et cetera

#3

would i need to make b, a list, or how would it know to use each letter in b instead of the whole string?

this still returns the same input

def anti_vowel(text):
    l = list(text)
    b = "AEIOUaeiou"
    x = []
    for c in l:
        for char in b:
            if char not in l:
                x.append(c)
            
        x = ''.join(l)
        return x

also tried this

def anti_vowel(text):
    l = list(text)
    b = list("AEIOUaeiou")
    x = []
    for c in l:
        if c not in b:
            x.append(c)
            
        x = ''.join(l)
        return x

#4

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