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 trialyoussef moustahib
2,303 PointsWhat is wrong with my code? Python
"OK, I need you to finish writing a function for me. The function disemvowel takes a single word as a parameter and then returns that word at the end. I need you to make it so, inside of the function, all of the vowels ("a", "e", "i", "o", and "u") are removed from the word. Solve this however you want, it's totally up to you!"
I don't understand what I am doing wrong. I've made the vowels variable, i turned word into a list, I then changed word further by lowercasing everything inside.
my for loop looks ok and I turned word back into a string... HELP!!
Thanks
def disemvowel(word):
vowels = ['a', 'e', 'i', 'o', 'u']
word = list(word)
word = word.lower()
for letter in word:
if letter in vowels:
word.remove(letter)
return ''.join(word)
youssef moustahib
2,303 PointsHi Garett,
That still doesn't work
Garett Haight
16,632 PointsWorks fine when I run it: https://repl.it/I2dq/0
youssef moustahib
2,303 PointsHi Garett
On your link, when I run the code with the string argument("aeiou") I get back "eo"
Garett Haight
16,632 PointsOh, I see the problem. You're running for loop over word while resizing the word, which causes some letters to be skipped.
Check this updated link for a working version: https://repl.it/I2dq/1
youssef moustahib
2,303 PointsHi Garett,
Your code is still returning vowels
Garett Haight
16,632 PointsLooks like I saved the wrong version.
Garett Haight
16,632 PointsGarett Haight
16,632 PointsYou need to call word.lower() before turning it into a list.