Welcome to the Treehouse Community
Looking to learn something new?
Daniel D'luyz2,880 Points
This editor does not check correctly the answer
I've tried 3 different solutions and they all work on the workspace, but this editor keeps telling me that the string I am returning contains the vowels.
This is the last solution I tried checking:
to_remove = ["a","A","e","E","i","I","o","O","u","U"] def disemvowel(word): while len(to_remove) > 0: letter = to_remove word = word.replace(letter, '') to_remove.remove(letter) return word
And before that:
to_remove = ["a","A","e","E","i","I","o","O","u","U"] def disemvowel(word): word_list = list(word) while len(to_remove) > 0: letter = to_remove while True: try: word_list.remove(letter) except ValueError: to_remove.remove(letter) break return ''.join(word_list)
Jennifer NordellTreehouse Teacher
Hi there, Daniel D'luyz ! You're doing terrific and your logic is pretty solid. However, you haven't taken into account what happens when your
disemvowel function is run more than once. Because you declared the list holding the vowels outside`of the function, once the function completes that list is no longer filled with vowels. It is, in fact, empty. So the second time that function is run, the vowels will not be removed.
To mitigate this, you can place the declaration of the
to_remove list as the first line inside your function. That way, every time the function is run, the vowel list will be reset.
Hope this helps!