Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Collections (2016, retired 2019) Lists Disemvowel

Waleed Aljarman
Waleed Aljarman
Courses Plus Student 947 Points

removing vowels

what is wrong with the code, do i have to make word.lower in the start of the code or is there a mistake in what i wrote.

def disemvowel(word):
list( word)

for letters in word:
    if letter == 'a':
    if letter == 'A':

    if letter == 'e':
    if letter == 'E':

    if letter == 'o':
    if letter == 'O':

    if letter == 'u':
    if letter == 'U':

    if letter == 'i':
    if letter == 'I':

return word

2 Answers

Afloarei Andrei
Afloarei Andrei
5,163 Points

I found some mistakes:

  1. you have a white space in 'list( word)' and also if you want to use that line you need to assign a variable.
  2. 'for letters in word' does not work because the 'word' is a string not a list. do the 1. if you want you'r for loop to work.
  3. in you'r 'for' loop you use the word 'letters' and after in 'if' you use 'letter'

If you correct those the code won't pass. Read this post if you didn't figure it out, it will help you understand why is not passing:


Waleed Aljarman
Waleed Aljarman
Courses Plus Student 947 Points

i read the link you sent me and it helped a lot, but i still have a problem, i think it is with converting the list to a string

""" def disemvowel(word):

n_vowel= []
word = list(word)
for letter in word:
    if letter.lower() not in ['a', 'e', 'i', 'o', 'u']:

word = n_vowel
word = str((' ').join(word))

return word """
Afloarei Andrei
Afloarei Andrei
5,163 Points

The last part, after 'continue', remove it. Leave just the 'return'. Now, you have to return all the characters from 'n_vowel' JOINED together in a string. And you don't need to use 'str()' to do that because " ' '.join()" returns a string

Waleed Aljarman
Waleed Aljarman
Courses Plus Student 947 Points

i re-read your comment and the example you gave me, it really helped. Thanks