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 PointsStill not understanding this very well
Someone else tried answering this for me but I still can't get it
def disemvowel(word):
for letter in word:
if letter.lower() == 'a' or 'e' or 'i' or 'o' or 'u':
list(word)
word.remove(letter)
''.join(word)
return word
1 Answer
bryonlarrance
16,414 PointsA couple things that might help.
This site is great for visualizing your code http://pythontutor.com/
Also, you can go the list route, but I think it is a bit more condensed to keep your word as a string.
I created a new_word. Searched for every letter in that word that is NOT in the string 'aeiou'
Then I added or concatenated the letters that are not vowels into my new_word.
def disemvowel(word):
new_word = ''
for letter in word:
if letter.lower() not in 'aeiou':
new_word += letter
return new_word
Put this code in python tutor and it might help to see the process in real time.
def disemvowel(word):
new_word = ''
for letter in word:
if letter.lower() not in 'aeiou':
new_word += letter
print (new_word)
disemvowel('gCCeoriiiiige')