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 trialNikki Wong
9,066 PointsI have ensured that all letters are small before I check..
So where am I going wrong? I loop through every letter in the word and I remove the original letter that is contaiend in vowels...What am I doing wrong?
def disemvowel(word):
vowels = ["a", "e", "i", "o", "u"]
wordList = list(word)
for letter in wordList:
letterEdit = letter.lower()
if letterEdit in vowels:
wordList.remove(letter)
result = ("").join(wordList)
return result
1 Answer
Kip Yin
4,847 PointsYou are iterating AND changing the iterable at the same time! So every time you remove an element from the list, your loop gets shortened...
Simply change to
for letter in list(word):
...
will do.
Kip Yin
4,847 PointsKip Yin
4,847 PointsP.S. this challenge can be done in one line : D
def disemvowel(word): return "".join(list(filter(lambda x: x if x.lower() not in "aeiou" else "", word)))
Nikki Wong
9,066 PointsNikki Wong
9,066 PointsAh ok!!! I completely missed that one!! Thank you!