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 trialMaiia Spivak
3,038 PointsI am stuck with this one!
Could anybody share the script?
def disemvowel(word):
vowels = ['a', 'e', 'i', 'o', 'u']
if vowels in word:
word.remove(vowels)
else:
pass
return word
Maiia Spivak
3,038 PointsQuestion:
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!
1 Answer
Steven Parker
231,269 PointsIt looks like you have the basic idea but need to take it a bit farther.
So here's a few hints:
- the remove method is for lists, a string would need to be converted first
- the remove method only removes the first occurrence of the specified item
- you will need a loop if you want to remove every occurence
- you might also need a loop to test and remove each vowel one at a time
- you may also need to check for and remove upper-case vowels
- you don't need to worry about exceptions for this challenge
Maiia Spivak
3,038 PointsMaiia Spivak
3,038 PointsOne more try:
def disemvowel(word): try: if 'a' in word: word.remove('a') elif 'e' in word: word.remove('e') elif 'i' in word: word.remove('i') elif 'o' in word: word.remove('o') elif 'u' in word: word.remove('u') except ValueError: pass return word
I know, something's missing there..