Welcome to the Treehouse Community
Looking to learn something new?
David Chia6,988 Points
Why is my code not working as expected?
I tested my code with "adsfQWERuiOp" But the result was 'dsfQWRip'
Why is the 'i' still in the word?
def disemvowel(word): ls = list(word) for alpha in ls: if alpha.lower() in "aeiou": ls.remove(alpha) word = ''.join(ls) return word
Ryan S27,276 Points
The issue of skipping vowels arises when you modify the same list that you are iterating through. Any time you have two vowels in a row, the second one will be skipped over because the indexes in the list will shift once you remove the first vowel.
One way around this is to iterate through a copy of the list, but still remove vowels from the original. Recall that a quick way to make a copy is by using slices (eg.,
Hope this helps.