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

List inside of a list will not remove?

I'm undertaking the python introduction course & I'm trying to remove a list within a list, but to no avail..

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

newstates.remove(['red', 'green', 'blue'])

I'm aware I've used 'newstates' above, but even using 'states' is incorrect..

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing great and it actually would work if you had states there. But you missed something else. Take a look at this tip provided by Treehouse.

Important: In each task of this code challenge, the code you write should be added to the code from the previous task.

In step 1 you removed the 5 inside of states. But because you deleted that line, the ending set that the challenge is getting back isn't correct, because now it has a 5 inside of it where it should be gone. Your code in these challenges should be cumulative. If you add the line back to remove the 5 before you remove the list, your code passes step 2 with flying colors! Also, change it back to states.

Hope this helps! :sparkles:

Aha! Yes, I got it now, cheers!