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!
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
Ashikur Rahman
Python Web Development Techdegree Student 932 PointsWrote correct code but it's showing error
Hi! I wrote correct code and checked it but it's throwing an error and I can't fix it. could you please help out? Thanks in advance
def disemvowel(word): word = list(word.lower()) vowels = ['a', 'e', 'i', 'o', 'u'] for letter in vowels: if letter in word: word = word.replace(letter, "") word = "".join(word)
return word
2 Answers

ds1
7,627 PointsHi, Ashikur
def disemvowel(word):
vowel_list = list('aeiou') #makes a list out of this string of vowels (you don't have to do it this way)
word_list = list(word)
good_list = []
for letter in word_list:
if letter.lower() not in vowel_list:
good_list.append(letter)
word = "".join(good_list) # joining the list back into a string
return word

Steven Parker
224,848 PointsThe code may not be as "correct" as you think:
Letters that are not removed should remain unchanged, but your code converts all letters to lower case.
Also, you only need to define the function, you won't need to call it or to print anything.