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

Python Python Collections (2016, retired 2019) Lists Disemvowel

OK, I need you to finish writing a function for me. The function disemvowel takes a single word as a parameter and then

i need pointers on this

disemvowel.py
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)
            return final_result

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're actually pretty close here, but here are some things to take a look at.

  • Your if statement will always evaluate to true. Only one thing in an or statement needs to be true for the whole thing to evaluate to true and there are no uppercase letters in your vowells list.
  • The challenge asks you to return a string, but you are currently returning a list
  • You may not set the value of word yourself inside the challenge. This can throw off the results.
  • Check the placement of your return statement. Currently, it resides inside the if statement. Remember that once a return statement is hit, the function ceases execution. At this point, your code will only ever return a list containing exactly one letter.

I suggest you try this in workspaces so that you can get a better idea of what is happening.

Hope this helps! :sparkles: