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 trialNikolay Komolov
23,033 PointsDisemvowel function seems to work but the test doesn't pass
Hello everybody. I tested this code and it seemed to work. However, the test doesn't pass. Have I done anything wrong here? Thanks!
def disemvowel(word):
word = list(word)
for letter in word:
if letter.lower() in 'aeiou':
word.remove(letter)
return ''.join(word)
3 Answers
Abdishakur Hassan
3,585 PointsThis works. I havent got it through first time i was on mobile device.
def disemvowel(word):
my_list = list(word)
for letter in word:
if letter in "aeiouAEIOU":
my_list.remove(letter)
word = "".join(my_list)
return word
Daniel Schmidt
9,780 PointsTry this:
def disemvowel(word):
vowels = ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')
return ''.join([letter for letter in word if letter not in vowels])
If your not familiar with this syntax check out this course Python Comprehensions
Abdishakur Hassan
3,585 PointsYou are very close. Almost done.
Instead of returning the joined word ''' return ''.join(word) ''' first seperate the list and the word
create new list out of the parameter word and use that to join with the word
def disemvowel(word):
my_list = list(word)
for letter in word:
if letter.lower() in 'aeiou':
my_list.remove(letter)
word = ''.join(my_list)
Savannah Logan
974 Pointsi tried exactly what you out and it is still not passing....