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 trialKade Carlson
5,928 PointsJust came back to this challenge from trying it a couple weeks ago. Not sure what to do here
I'm really stuck on this one
def disemvowel(word):
return word
for letter in word:
if letter.lower() == 'a' || 'e' || 'i' || 'o' || 'u':
word.remove(letter)
else:
None
2 Answers
James Shi
8,942 PointsIn python, you want to use or
instead of ||
. Your expression only checks whether the letter is 'a' or one of the other letters has a true value. A better way to check if a letter is a vowel is by checking whether the letter is in a string containing all vowels.
if letter.lower() in 'aeiou':
Also, strings are immutable, so you can't remove a letter from a string. Instead, you could convert the string to a list, remove elements from the list, and convert the list back to a string.
A couple of other things to note, put a return statement at the end of the function rather than the beginning, and make sure you iterate through all letters in the word. Deleting letters while iterating forwards can cause you to skip a letter.
Jonathan Rhodes
8,086 PointsIn addition to the answer above, your return statement is right after the function is defined, resulting in the function's code never really executing.