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 trialVasiliki Karagiorgi
1,598 PointsHello everyone, I want a bit of help with the Challenge 1 of Python Collections.
I don't really understand what I am doing wrong. After checking the answer, it comes back with SyntaxError.
Any help, would be much appreciated.
def disemvowel(word):
vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
if vowels in word:
word = letters []
try:
letters.remove(vowels)
except ValueError:
pass
else:
return word
1 Answer
Steven Parker
231,269 PointsThe syntax error is on this line:
word = letters []
The issue is that "letters" has not been defined. Perhaps you meant to create a list named "letters" using "word"? That would be:
letters = list(word)
And while not a syntax error, this line will cause another error:
if vowels in word:
Since "vowels" is a list and word is a string, the mismatched types won't work with the membership operator.
You'll still have some work to do, but it should run after you fix these.
nakalkucing
12,964 Pointsnakalkucing
12,964 PointsTry appending your consonants to a list and returning that list. Rather than trying to remove your vowels. Hope this helps and I'd be glad to give any more help you need with this one. I struggled through it too. :)