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 trialMorten Egge
1,898 PointsError on disemvowel
keep getting error on my code, it works in console..
def disemvowel(word):
vowel = 'AEIOU'
mod_word = ""
for i, v in enumerate(word.upper()):
if not v in vowel:
mod_word += v
return mod_word
1 Answer
Michael Hulet
47,913 PointsIn this case, it's a casing issue. The word you return needs to match the case of the word that's passed in. For example, if the function takes the string "no vowels"
, it expects to get back "n vwls"
, not "N VWLS"
. At the beginning of your loop, you're converting the entire word to be uppercase, so when you build mod_word
, all the letters will be unconditionally capital. It'd be better if you converted each individual letter to uppercase when you check to see if it's a vowel instead. That way, you can still keep a list of just the uppercase values, and you still have access to the properly-cased value to append to mod_word
Morten Egge
1,898 PointsMorten Egge
1,898 PointsThank you ! I i changed the code to" for i, v.upper()" Worked like a charm.