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 trialGilang Ilhami
12,045 PointsI'm trying to solve the Disemvowel challenge with `try`
I'm trying to solve the challenge using try and except
But it seems there is something that I am missing
def disemvowel(word):
letters = list(word)
vowels = ["a", "e", "i", "o", "u"]
for i in vowels:
upper = i.upper()
if i in letters or upper in letters:
try:
letters.remove(i)
except ValueError:
print("No Vowels here")
return letters
word = ''.join(letters)
return word
return word
2 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsyou have three returns, you only need one. the program exits when it hits a return, so it's exiting earlier than is necessary to remove the vowels.
Tom Miller
2,640 PointsYou are testing for lowercase (i) and uppercase (upper) vowels, but only trying to remove the lowercase ones remove.(i) so you could be trying to remove the letter 'e' from the word 'Error'.
Gilang Ilhami
12,045 PointsGilang Ilhami
12,045 PointsI've tried removing the returns, but it still wont't run