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 trialAlejandro Byrne
2,562 Points.remove challlenge
What's my problem? Why does my code not work? I think I have it all, the remove, except ValueError, and the upper and lower cases...
def disemvowel(word):
try:
word.remove('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U')
except ValueError:
pass
return word
1 Answer
Alexander Davison
65,469 PointsThere are two mistakes:
- Python doesn't have a method called
remove
on strings. It only has that method on lists. - Even if you first convert the string into a list, the
remove
method on lists doesn't support to remove multiple arguments at once. You shouldn't make up your own way of using a function, it might not work! You should always check the documentation for new functions. - Lastly,
remove
only removes the FIRST element that's the vowel.
EDITED
Solution:
def disemvowel(word):
result = ''
for letter in word:
if letter.lower() not in 'aeiou':
result += letter
return result
I hope this helps. ~Alex