Anti_vowel exercise


Hi there,

noobie here, can anybody tell me why this doesn’t work?

def anti_vowel(text):
  list_text = list(text)
  for char in list_text:
    if char in "ieaouIEAOU":
  word = ''.join(list_text)
  return word

The error message at the bottom says:
Your function fails on anti_vowel(“Hey look Words!”). It returns “Hy lk Words!” when it should return “Hy lk Wrds!”.



Hi @weifchen,

You are reducing the size of list_text as you iterate through it, which shifts the positions of the elements within it, thereby interfering with the iteration.

Instead, you should start with a new empty list and iterate through text, placing characters that are not vowels into that new list.


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