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 trialmaike willuweit
552 PointsHow to remove an item in a list with the .remove() option? Basic course exercise
I am learning the python basic course. How to remove items in a list using the .remove() option.
I have had various attempts, but seem to miss out some basic part / parts...
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
my_list = ['ACTIVE', ['red', 'green', 'blue'], 'CANCELLED', 'FINISHED', 5,]
list_in_list = ['ACTIVE', ['red', 'green', 'blue'], 'CANCELLED', 'FINISHED', [5,]]
list_in_list.remove([5,])
2 Answers
Jennifer Nordell
Treehouse TeacherHi again, maike willuweit! I regret that the hints I left in this post weren't enough to get you through the first step of the challenge.
Here is my solution:
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove(5)
This line runs the remove method on the states
list and removes the 5. Only this line is needed for the first step.
Hope this helps!
maike willuweit
552 PointsThanks again, I re-posted this one as I wasn't sure if my initial question was posted... Your first comments / hints were good!
eric bates
863 Pointseric bates
863 Pointssame thing i was just trying to figure out