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

Waleed Aljarman
PLUS
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.

disemvowel.py
def disemvowel(word):
list( word)

for letters in word:
    if letter == 'a':
        letter.remove('a')
    if letter == 'A':
        letter.remove('A')

    if letter == 'e':
        letter.remove('e')
    if letter == 'E':
        letter.remove('E')   

    if letter == 'o':
        letter.remove('o')    
    if letter == 'O':
        letter.remove('O')    

    if letter == 'u':
        letter.remove('u') 
    if letter == 'U':
        letter.remove('U')    

    if letter == 'i':
        letter.remove('i')
    if letter == 'I':
        letter.remove('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:

https://teamtreehouse.com/community/my-disemvowel-function-isnt-passing-the-challenge

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']:
        n_vowel.append(letter)
    else:
        continue 

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