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 trialWendi Bao
1,150 PointsI don't know what is wrong with this coding
I tried to use the remove method but failed, and I hope you could help me fix my code
def disemvowel(word):
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
for letter in word:
if letter in vowels:
word.remove(letter)
return word
1 Answer
Steven Parker
231,269 PointsStrings don't have a "remove" method, were you thinking of using "replace"?
Wendi Bao
1,150 PointsWendi Bao
1,150 PointsSo if I want to use the remove method, I have to change the string into list first? But I am not sure how to do this. I actually want to use the remove method not replace
Steven Parker
231,269 PointsSteven Parker
231,269 PointsSure, that's another way to go. Change the string to a list, make the changes to it with "remove", and then join it back into a string to return it.
If you go that way, be sure to use a copy of the list for looping to avoid problems with items being skipped.