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 trialMohsan Chaudhry
1,469 PointsCode words in workspace, but not for exercise
I tried this code in workspaces and it worked. But I'm not passing the test. I'm not sure where I'm making the error.
Thanks for the help
def disemvowel(word):
word_list = list(word)
index = 0
for index in range(len(word_list)):
if 'a' in word_list:
word_list.remove('a')
elif 'e' in word_list:
word_list.remove('e')
elif 'i' in word_list:
word_list.remove('i')
elif 'o' in word_list:
word_list.remove('o')
elif 'u' in word_list:
word_list.remove('u')
else:
index += 1
continue
new_word = ''.join(word_list)
return new_word
3 Answers
Chris Freeman
Treehouse Moderator 68,441 PointsYou are very close. Be sure to check for upper AND lower case vowels!
Mohsan Chaudhry
1,469 PointsI tried to make the word all lower case before it goes into the loop in 2 different ways, both of which didn't work.
word_lower = word.lower() word_list = list(word_lower)
or
word_list = list(word.lower())
Thank you for your help!
Chris Freeman
Treehouse Moderator 68,441 PointsI tried a brute force test of expanding the if/elif
code to also check for the uppercase versions and it passes the challenge.
Mohsan Chaudhry
1,469 PointsThanks for the help! It worked after I added more elif statements to check for uppercase.
Chris Freeman
Treehouse Moderator 68,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsWhile a brute force approach works, please explore the other solutions for this challenge here