Welcome to the Treehouse Community
Looking to learn something new?
What is wrong with this code?
What is wrong with my code?
def disemvowel(word): char_list = list(word) char_remove = set(('a','e','i','o','u')) for char in char_list: if char.lower() in char_remove: char_list.remove(char) word = ''.join(char_list) return word
Dave StSomeWhere19,822 Points
The issue is that your are looping through a list and modifying that list while in the loop, so it is messing up the loop when you remove a character. It will skip the next character after a remove because you modified which character is at the next index entry value.
Probably the easiest fix is to just loop over
word (of course there are zillions of other options)...
Please let me know if you need additional explanation.
Yes I've got it now, it works.
Thanks a lot Dave.