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 trialBarak Eyala
Courses Plus Student 1,088 PointsTrouble with the challenge.
I am not sure why my code isn't working any ideas?
def disemvowel(word):
split_word = word.split()
all_vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
for vowel in all_vowels:
try:
split_word.remove(vowel)
except ValueError:
continue
word = "".join(split_word)
return word
1 Answer
Martynas Matimaitis
10,480 PointsHi,
When I copied your code and tried running it first problem was it had indentation issues but that might be only an issue with my text editor.
Secondly, the method remove() works only with lists (ref: https://www.programiz.com/python-programming/methods/list/remove) and doesn't help when trying to remove a character from a string. One method that could help you is replace():
new_string = old_string.replace("char_to_replace", "char_to_replace_with")
Other way could be using regular expressions with the help of RE library (ref: https://docs.python.org/3/library/re.html)
Hope this helps!