My code generally works fine for removing vowels. However, when the argument string contains a word with two of the same vowel next to each other, such as "look" it will only remove the first vowel, giving "lok". This is made more confusing if more of the same vowel appear later in the string. For example, "look on" returns "lk on".
This issue only appear when vowels are next to each other. For example "there isn't any explanation for this!", with multiple i's and e's removes all vowels correctly.
Thinking through the iteration that is taking place I can't understand how this would happen, any thoughts?
My initial idea was that because that character was removed, the next character would be moved to the index of the previous and so would be skipped. However, the "look on" returning "lk on" example shows this can't be the case.
I'd really appreciate any feedback! I understand this can probably be approached numerous other ways but I think it would be a great learning point to understand why this is happening. Thanks in advance!
def anti_vowel(text): vowels = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u'] text_list =  for char in text: text_list.append(char) print text_list for i in vowels: for char in text_list: if char == i: print char," Removed" text_list.remove(char) print text_list text_no_vowels = "" for char in text_list: text_no_vowels += char print text_no_vowels return text_no_vowels anti_vowel("Look over there on the hill!")