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()

where do I put .remove in this?

Where does it go in the code?

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

2 Answers

Steven Parker
Steven Parker
231,236 Points

You have the right idea. But the last item of the (main) list is 5.

Ryan Cross
Ryan Cross
5,742 Points

del states[1][2] will remove blue by removing the index 2 item from in the index 1 item in states you can't remove 'blue' from states because states contains ['ACTIVE',['red', 'green', 'blue'],'CANCELLED','FINISHED', 5,] which can be considered [a string, a list, a string, a string, an int] it has strings but not string == "blue" it has the value"blue" but not as a standalone string, it has it as a member of a list i really hope this helps

Steven Parker
Steven Parker
231,236 Points

But "blue" is not the item that task 1 is asking you to remove.

Ryan Cross
Ryan Cross
5,742 Points

Oh. Well I didnt know that. He certainly seemed by the question to be asking for help with remove and by the code sample it looks like he was incorrectly attempting to remove blue. Maybe I misunderstood him.