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 trialJoseph Ferrero
1,308 PointsWhy is my code not working? I have tried it on my own and it seems to be working fine.
Cant figure out why its not working.
vowels = ['a', 'e', 'i', 'o', 'u']
def disemvowel(word):
word = word.lower()
word = list(word)
for letter in vowels:
if letter in word:
word.remove(letter)
return(word)
2 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYou have the right idea. Your code will pass with theses corrections:
add uppercase vowels to the vowels
list
remove statement using lower()
flip the for
and if
object targets. For each letter in the word
check if the letter is in the vowels list
join()
the word
list into a string before returning it.
Wait! Try to fix your code using the hints above before looking at the corrected code
Here's the corrected code:
vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
def disemvowel(word):
word = list(word)
for letter in word[:]:
if letter in vowels:
word.remove(letter)
return "".join(word)
Alex Diaz
4,930 PointsPretty sure if you make your vowels list include both under and uppercase letters, it'll help. The challenge says to make sure to check for upper and lowercase letters :) Saying that, you're not going to need the word = word.lower() line as well. Hope I helped!
Joseph Ferrero
1,308 PointsThat is still not working, ay other ideas?
Joseph Ferrero
1,308 PointsI know what the problem is, the loop stops once it finds vowel and then misses the same vowel if it comes up again in the word. Any idea how I can do that? I am thinking I need to use "pass" in some way but I tried and it didn't work.