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 trialRaul Gutierrez
2,601 PointsCan someone tell me how to solve this problem? I'm having trouble. Thanks
I don't know how to do it
def disemvowel(word):
while 'a' in word:
word.remove('a')
while 'e' in word:
word.remove('e')
while 'i' in word:
word.remove('i')
while 'o' in word:
word.remove('o')
while 'u' in word:
word.remove('u')
return word
2 Answers
Emeka Okoro
Courses Plus Student 11,724 Pointsdef disemvowel(word): vowels = 'aeiou' word = list(word) for i in word: if i in vowels: word.remove(i) return ('').join(word)
what that does is save the vowels to a string 2 creates a list of each letter in the word - (did this cos lists are mutable and strings aren't) 3 runs through each word in the list, checking to see if it is contained in the vowels variable('aeiou') if it is, remove it. if not, on to the next 4 returns the list which is what's left after removing vowels and joining back together
Sorry if it's not well formatted. first time answering a question. lol!
Kenneth Love
Treehouse Guest Teacherword
is a string and strings are immutable, so you can't do word.remove()
, as the word
can't be changed in place.