8/15 I don't know what's wrong with my solution


#1

Here is my code
def anti_vowel(text):
letters = list(text)
for i in letters:
if i in "aeiouAEIOU":
letters.remove(i)
return "".join(letters)

But, anti_vowel("Hey look Words!"). It returns "Hy lk Words!" when it should return "Hy lk Wrds!".
Why only the vowel in the last word is not removed??
help me please
thanks!


#2

I had the same issue (and then a similar one when I tried to fix it, where it deleted extra letters that were near vowels). I'm not sure exactly what is causing it, but I managed to get around it by by using "not in" instead of "in", and just adding the letters in the same check, rather than removing vowels first.

For reference, here's my code:

def anti_vowel(text):
    a = []
    for letter in text:
        a.append(letter)
    text = ''
    for letter in a:
        if letter not in 'AEIOUaeiou':
            text += letter
    return text

Probably not the cleanest code but it passed. EDIT: Thanks to rydan, formatting achieved.


#3

Hey guys

Hope everyone is having a great time coding

if you want to format your code when you paste it here you have three options

  1. select the code (after you paste it here) and press ctrl + k or
  2. select the code(after you paste it here) and press </> in the tools pane
  3. put this character ` three times at the begining and end of code