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 trialLukas Coffey
20,382 PointsFunction works in local environment but not in Challenge
On my local machine this returns the correct results. For instance: disemvowel("Vowel") = "Vwl"
def disemvowel(word):
list_word = list(word)
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
for letter in list_word:
if letter in vowels:
list_word.remove(letter)
new_word = "".join(list_word)
return new_word
1 Answer
james south
Front End Web Development Techdegree Graduate 33,271 Pointstry it with a word that has consecutive vowels. it won't work because you are modifying a list while looping through it. the remove method takes the specified element out, then all elements after that element shift left. the loop moves on though, resulting in skipped elements. to solve make a copy of the list and loop through that while modifying the original (or vice versa) and it won't skip elements any more.