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 trialSean McKee
461 PointsI put states.remove([5]) but it tells me that 5 is not in the list please help.
When I try to remove anything it says it is not in the list, but it clearly is.
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove([5])
1 Answer
Tobias Helmrich
31,603 PointsHey there Sean,
if you want to remove the item with the value of 5 from the states list you must not write it inside of square brackets. You just write the value inside of the remove method.
states.remove(5)
If you would want to remove the value by its index inside of brackets you could write it with the del keyword like so:
del states[4]
Note that the index of the item with the value of 5 in the states list is 4 because the index of lists starts with 0.
I hope that helps! :)