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

Having trouble with my understanding and solving this challenge - help is much appreciated!

Hello everyone,

I've been trying to solve this problem for some time now, and have had no success so far.

I'm concerned that my logic is flawed somewhere, and I can't identify what I'm missing here.

I've attached my latest attempt at coding a solution, and some advice in where my thinking needs adjustment would be much appreciated, as I'd like to be able to figure out a solution for this challenge.

Many Thanks in advance!

Kind Regards

disemvowel.py
def disemvowel(word):
    vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]

    disemvoweled_word = []

    for letter in word:
        if letter not in vowels:
            disemvoweled_word.append(letter)
            return disemvoweled_word
        else:
            break

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

You headed in the correct direction!

  • if a non-vowel is the first character, the else/break causes the loop to end result in a default return None. :point_right: remove the else/break
  • if a vowel is the first character, it is appended to disemvoweled_word then returned immediately. :point_right: move the return statement outside of for loop
  • the expected return object should be a string. :point_right: use "".join() on disemvoweled_word to get a string

Post back if you need more help. Good luck!!!

Thank you for your assistance Chris!