8. anti_vowel help


#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!".

It should be returning new[] but with all of the consonants joined together, but it's only print out "Hey Yo!"


def anti_vowel(text):
    vowels = ['A','a','E','e','I','i','O','o','U','u']
    new = []
    s = ""
    for char in text:
        for c in vowels:
            if c == 'u' and c != char:
                new.append(char)
    return s.join(new)
    
print anti_vowel("Hey You!")


#2

Hi ,
Just had a quick look at your code.
1) for c in vowels: ----> You are checking the condition, so use "if not in "
in the place of for loop and
also when not found in the vowels list, try to append.
2) if c == 'u' and c != char: This line is not necessary.


#3

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