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 trialmamadou 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,441 PointsYou have the right idea but there a few errors to fix
- the
return
statement is indented to far. This causes the function to return after completing the first pass through thefor
loop -
final_list
is 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_list
is 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
if
condition is not correct. Each side of theor
must be complete comparisons. Simply havingletter.lower()
before theor
will 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 thevowels
list, the fullif
condition 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,441 PointsChris Freeman
Treehouse Moderator 68,441 PointsAlmost there. Two more errors:
final_result
should be the argument to thejoin
functionword = "treehouse"
as it overwrites the argument passed into the function.