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

I need you to make it so, inside of the function, all of the vowels ("a", "e", "i", "o", and "u") are removed from the w

Can someone look into my code and see why are not running and if also I ma getting the right answer?

disemvowel.py
vowels=['a','e','i','o','u','A','E','I','O','U']
def disemvowel(word):
    word_letters = list(word)
    letters=[]
for letter in word_letters:
    if letter in vowels:
            word_letters.append(letter)
    if letter in letters:
        word_letters.remove(letter)
        word1= word.join(word_letters)
    return(word1)

1 Answer

Steven Parker
Steven Parker
229,786 Points

You seem to have the right idea, but a few issues:

  • you probably don't want to append anything additional to the word
  • removing from the iterable controlling a loop can cause things to be skipped (use a copy for the loop)
  • check indentation, anything in a function must be indented more than the "def" line
  • it doesn't seem like "letters" is needed
  • you probably don't want to use the original word as the join string
  • only join once, after the loop finishes