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 trialVic A
5,452 Pointswhat am i missing here?
This is a really amateur issue but what am I missing here?
def disemvowel(word):
vowels = "aeiouAEIUO"
for v in list(word):
for i in vowels:
word.remove(i)
return word
1 Answer
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou are looping through a list cast of word, but that is not actually casting word into a list, so when you call remove, you are calling it on a string which throws an error. so earlier in the body cast word to a list. then, you need a conditional statement comparing the letters in word to the vowels and removing if appropriate. it throws an error to try to remove an element that doesn't exist. thirdly, you are modifying a collection as you loop through it, which results in skipping elements, since removing an element shifts remaining elements to the left, while the loop counter moves on. so for instance you could make a copy and loop through that while modifying the original, or vice versa. finally, you are returning a list, not a string, so you need to join your resulting list back into a string.