Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVictor Gavojdea
11,796 PointsRemoving all vowels
Not sure why it's not passing, it works when I run it in PowerShell.
EDIT: Apparently this doesn't remove some vowels if they are right next to each other...
def disemvowel(word):
word = list(word)
vowels = ["a", "e", "i", "o", "u"]
for letter in word:
if letter.lower() in vowels:
word.remove(letter)
word = ''.join(word)
return word
1 Answer
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou are modifying a list while looping through it. when remove is called, it removes the indicated element, then shifts remaining elements to the left. the loop moves on to the next original element however, so elements get skipped. to fix you can make a copy of the list and loop through that while modifying the original or vice versa.
Victor Gavojdea
11,796 PointsVictor Gavojdea
11,796 PointsThank you!