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 trial
mamadou diene
Python Web Development Techdegree Student 1,971 PointsOK, I need you to finish writing a function for me. The function disemvowel takes a single word as a parameter and then
i am not passing this challenge
word = "Treehouse"
vowells = ["a", "e", "i", "o", "u"]
final_result = []
def disemvowel(word):
for letter in word:
if letter.lower() or letter.upper() not in vowells:
final_result.append(letter)
else:
continue
return final_result
2 Answers
Chris Freeman
Treehouse Moderator 68,468 PointsYou have the right idea but there a few errors to fix
- the
returnstatement is indented to far. This causes the function to return after completing the first pass through theforloop -
final_listis a constructed as a list, but a string is expected. Use"".join()to create the string - the challenge checker runs the function many times, but
final_listis initialized only once. This causes results from one test to be added to the next test. Move the initialization inside the function - the logic of the
ifcondition is not correct. Each side of theormust be complete comparisons. Simply havingletter.lower()before theorwill return a letter which is always considered "truthy" making the append happen every time. You could add a check for the lowered letter in the vowell list but sinceletter.upper()will never be found in thevowelslist, the fullifcondition can be reduced to checking whether the lowered lettered is in the list.
Post back if you need more help. Good luck!!!
mamadou diene
Python Web Development Techdegree Student 1,971 PointsYOU ARE A GODDD!! Thank you so much
mamadou diene
Python Web Development Techdegree Student 1,971 Pointsmamadou diene
Python Web Development Techdegree Student 1,971 Pointsi did these corrections:
And here is what i am getting now Bummer! SyntaxError: invalid syntax (disemvowel.py, line 10)
Chris Freeman
Treehouse Moderator 68,468 PointsChris Freeman
Treehouse Moderator 68,468 PointsAlmost there. Two more errors:
final_resultshould be the argument to thejoinfunctionword = "treehouse"as it overwrites the argument passed into the function.