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

Python Python Basics (2015) Python Data Types list.remove()

Daniel Lodestro
Daniel Lodestro
2,572 Points

ValueError, please help! (Python) This seems so easy, but what am I doing wrong?

There was only a 15 second portion of the video prior to this exercise that covered .remove. I'm confused since it looks so different from what was in the video. I guess I'm just not understanding the syntax or the method.

Thank you in advance!

lists.py
states = [
    'ACTIVE',
    ['red', 'green', 'blue'],
    'CANCELLED',
    'FINISHED',
    5,
]
states.remove(['blue'])

Are you ok with task 2?

I had received a message about you having trouble with that but I don't see it here.

1 Answer

Hi Daniel,

So in this first task you are being asked to remove the last item in the list. It's referring to the last item in the states list so you need to remove the 5.

The color list is a list within the states list. That entire list is considered an item or element of the states list.

If you did need to remove the "blue" then you have to access that list first and then call the remove method on that. That color list would be at index 1 within the states list.

So you could do

states[1].remove('blue')