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 trialAnurag k
902 Pointsdisemvowel
can some one please help me , why is this code to working ?
def disemvowel(word):
letters = ["a", "e", "i", "o", "u"]
word = word.lower()
w = list(word)
for i in range(len(letters)):
for i in range(len(letters)):
if letters[i] in w:
w.remove(letters[i])
word="".join(w)
return word
Anurag k
902 Pointsthis above code was working in the ide but not not working in the console ..
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsThe solution needs to preserve any capital letters that appear in the original word
. By lowering the entire word the capital letters are lost. The current approach does not handle if a letter appears multiple times in the word. One suggestion would be to reverse the comparison: Look to see if each lowered letter in word
is a list of vowels.
Post back if you need more help. Good luck!!
Wayne Jessen
11,593 PointsWayne Jessen
11,593 PointsIt looks like you are looping through the letters list twice, and using the same variable to do it. Your second loop i is overriding your first loop i. I would try removing that and see if works.