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 trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Sohail Mirza](https://secure.gravatar.com/avatar/0b70940f69e505dc2918e7c43bedc749?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Sohail Mirza
Python Web Development Techdegree Student 5,158 PointsWhy doesnt my code work
Please advise where am i going wrong this question
def disemvowel(word):
exception = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
test = list(word)
test.remove(exception)
return word
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe "remove" method only removes something that matches the argument, so if you pass it a list it will only remove an element that is an exact duplicate of that entire list.
And a few other hints:
- to remove individual letters, you will probably want to use a loop
- if you modify "test" but then "
return word
", the output of the function will be unchanged - there are possible solutions that do not require converting the string to a list
- if you do convert the word to a list, remember to convert it back to a string before returning it
![Kevin Apetrei](https://uploads.teamtreehouse.com/production/profile-photos/10720640/micro_Ozone_Logo.jpg)
Kevin Apetrei
2,447 PointsTip:
You can always use (.upper) or (.lower) to simplify the (exception).
E.g: exception.lower = ("a", "e", "i", "o", "u") or exception.upper = ("A", "E", "I", "O", "U") that makes it so if you use uppercase or lowercase it will still work.
Sohail Mirza
Python Web Development Techdegree Student 5,158 PointsSohail Mirza
Python Web Development Techdegree Student 5,158 PointsHi Steven
Thanks for your reply. I am slighty confused as i ran by own example and it did not work. fruits = ["apple", "pear", "banana"] choice = ["apple"] fruits.remove(choice)
in this example i get an error.
Why is this the case
Steven Parker
230,688 PointsSteven Parker
230,688 PointsLet's say you have this list "
test = ['a', 'b', 'c', 'd']
" and another list "bits = ['a', 'b', 'c']
".So if you do "
test.remove(bits)
" nothing will happen.But if you started with this list inside of a list instead: "
test = [['a', 'b', 'c'], 'd']
" and then did "test.remove(bits)
", that would leave you with just "['d']
" in "test" because part of test was another list that was exactly like "bits".Does that clear it up?