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 trialFranchesca Lamkin
Python Web Development Techdegree Student 2,392 PointsHow should I restructure this to remove the vowels?
I'm unsure how to proceed with passing this challenge and have tried various ways.
def disemvowel(word):
vowels=["a","e","i","o","u","A","E","I","O","U"]
for letter in vowels:
word.remove(letter)
return word
1 Answer
Travis Howk
7,169 PointsI don't think that remove is the best method to be using here. Try using replace instead. For example, I could replace each of the letters that are vowels with an empty string, so something like this:
word.replace(letter, "")
Let me know if that doesn't work. Be sure to upvote it if I helped at all.
Franchesca Lamkin
Python Web Development Techdegree Student 2,392 PointsFranchesca Lamkin
Python Web Development Techdegree Student 2,392 PointsThanks, Travis. We were given this challenge after learning remove. Here are the instructions provided...
OK, I need you to finish writing a function for me. The function disemvowel takes a single word as a parameter and then returns that word at the end. I need you to make it so, inside of the function, all of the vowels ("a", "e", "i", "o", and "u") are removed from the word. Solve this however you want, it's totally up to you! Oh, be sure to look for both uppercase and lowercase vowels!
Travis Howk
7,169 PointsTravis Howk
7,169 PointsThe problem with using the remove method is that the remove method will only remove the first instance of an item within the list. Thus, something like this could happen
You could fix this by making it check every single item in the word against every single vowel that you have, but that is a little time consuming (although it does work).