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!
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 trial
mi abutCourses Plus Student 317 Points
code challenge : disemvowel problem
I dont understand what is the problem . Would appreciate help :)
def disemvowel(word): removed_letters = ["a", "e", "i", "o", "u",",A","E","I","O","U"] list_word=word.split() for letter in list_word: if letter in removed_letters: list_word.remove(letter) return list_word
Mark Kastelic8,147 Points
No need to make the vowel string a list. Use lower() to eliminate the need to include both upper and lower case.
def disemvowel(word): new_word = '' for letter in word: if letter.lower() not in 'aeiou': new_word = new_word + letter return new_word
You can't split a word into characters with
split(). You can make a list of characters from a word by using
list_word = list(word)
Also, you're returning a list. The challenge says you have to return a word. So you'll have to join the characters back into a string before you return it.
Mark's solution is more elegant, but you have the general idea.