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 trialDain Lewis
1,187 Points"Can't find your disemvowel function" I can't seem to figure out what it wants.
Hello,
I can't figure out what code will satisfy this question. I have tried a variety of different solutions, but it still says it can't find my disemvowel function. Here is my current solution.
Any help would be much appreciated.
Best, Dain Lewis
def disemvowel(word):
vowels = ["A", "E", "I", "O", "U", "Y"]
new_word = list(word)
for l in new_word[:]:
if l.upper() in vowels:
new_word.remove(l)
elif l.upper() not in vowels:
continue
else:
break
word = new_word
word = ''.join(word)
print("{}").format(word)
return word
disemvowel(raw_input())
1 Answer
Louise St. Germain
19,424 PointsHi Dain,
The challenge is just expecting the disemvowel function, not any code that will call it. So you can take out the last line where you call the function (the program that checks the challenge code will take care of calling it).
Also your return is fine! And you do need it, because that's what provides the output from your function, which the challenge will be testing. That said, you're right, you can simplify the last bit of your code after the for loop:
# All this code...
word = new_word
word = ''.join(word)
# This print statement has a typo (problem with location of parentheses)
# but isn't actually needed anyway so you can just take it out altogether
print("{}").format(word)
return word
#... can be replaced by...
return ''.join(new_word)
I hope this helps!
Dain Lewis
1,187 PointsAh great, that worked. Thank you!
Louise St. Germain
19,424 PointsYou're welcome! Glad it worked out!
Dain Lewis
1,187 PointsDain Lewis
1,187 PointsSo my return doesn't need to be in here, maybe that's what it is? Also I don't actually need new_word in this, I can just do word itself once I added the [:] in, I only had 2 because I was trying to find a way to avoiding removing items from the list as it was iterated which resulted in some bugs.
I guess I'm struggling to figure out how to properly use return in this example, I'm assuming that's where the problem is.