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 trialArcee Palabrica
8,100 PointsPython collection Challenge Task 1 of 1 disemvowel.py - tried this code and works fine on my IDE but not on Treehouse.
Hey guys... I wanna make sure this code works correctly so tried using a different editor and it works! However when I apply them on the challenge it doesn't work... I don't know why.
def disemvowel(word):
word = list(word.lower())
vowels = ['a', 'e', 'i', 'o', 'u'] * len(word)
for x in vowels:
if x in word:
word.remove(x)
word = ''.join(word)
return word
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! It does work and it doesn't. It returns the word without the vowels. However, it alters the original casing of the word. What if I added this instruction to the challenge: do this while preserving the original casing of the word? For example, if we were to send in "Treehouse", I would expect it to give me back "Trhs". Your code is returning "trhs".
I think you can get it with these hints as only a few alterations are needed to your code, but let me know if you're still stuck!
Drew Greene
5,086 PointsI had my code set up the same but I didn't have " * len(word)" could someone explain why that is necessary?
Arcee Palabrica
8,100 PointsDrew Greene Hey man... I was actually looping through the "vowels" here instead of the "word". So basically what I was trying to achieve was to look at "each letter" of the "word", check if it has ('aeiou') then move to the next letter of the word. It'll work without the len() but only for words without two vowels in it... without the len() using my name "arcee" will give me "rce"... if I'm not mistaken using remove(), if there are two items in an/a iterable/list that are the same it can only remove one of them. You need to run remove() again to take out the second one.
That's just how I understand it. Still learning... :) and open for more inputs and ideas.
Arcee Palabrica
8,100 PointsArcee Palabrica
8,100 PointsJennifer Nordell Hey you're right... Thanks so much. It works!