Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!

states = [
    ['red', 'green', '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