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 trialOllie Webster
5,035 PointsDisemvowel producing some strange results!
I am having some trouble with this question. Apparently it is returning some vowels and some consonants, but thinking through the code, I cannot see why. Is anyone able to help? I will continue to check it and let you know if I come to a solution.
def disemvowel(word):
word_list = list(word)
for letter in word_list:
if letter.lower() == "a" or "e" or "i" or "o" or "u":
word_list.remove(letter)
word = "".join(word_list)
return word
1 Answer
Ollie Webster
5,035 PointsI have now fixed it. The problem was removing letters from the list as the for loop was trying to cycle through them, leading to a mismatch in indices. This was solved my creating a new list with the letters to be kept and adding consonants to that.