Trouble with anti_vowel


#1



anti_vowel

the code appears to be ignoring the IF condition

it should return "Hy lk wrds!" when the input is "Hey look words!"


def anti_vowel(x):
    newstr=""
    for y in range(0,len(x)):
        if y!="a" and y!="e" and y!="i" and y!="o" and y!="u" and y!="A" and y!="E" and y!="I" and y!="O" and y!="U":
            newstr+=x[y]
    return newstr


#2

y is just a number, the index of your letters in your string x. so you don't need:

if y!="a"

you need:

if x[y]!="a"

if you add a print statement:

for y in range(0,len(x)):
   print y

you will see y is a number, a number doesn't equal a letter, so your if is "ignored" if you like