8. Anti-Vowel


#1

Curious as to why this isn't working. It throws the error: Oops, try again. Your function fails on anti_vowel("Hey look Words!"). It returns "bcdHy lk Wrds!" when it should return "Hy lk Wrds!".

How are these random extra letters being added?

Also, I seem to be having trouble getting any for loops to work properly usually mine only iterate once. Is this an indentation issue?

This is the problem, if you need to look at it.

vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
result = []
def anti_vowel(text):
    for char in text:
        if char not in vowels:
            result.append(char)
    return ''.join(result)

#2

Can you try to define the empty list "result" inside the function !!


#3

It worked! Why does it have to be defined within the function, though?


#4

So you can modify it inside the function , if it's out the function it can be used before the function call it ( like your example ; bcd this extra letters )
and it's just empty list , you wanna use it every time you call the function !