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

Nursultan Bolatbayev
Nursultan Bolatbayev
16,774 Points

Struggle in Python basics - list.py exercise, question 2

Hello. Here I do this: states.remove(['red', 'green', 'blue']). It doesnt work. But the same code I checked on workspace it worked

lists.py
states = [
    'ACTIVE',
    ['red', 'green', 'blue'],
    'CANCELLED',
    'FINISHED',
    5,
]
states.remove(5)
Nursultan Bolatbayev
Nursultan Bolatbayev
16,774 Points

The question asked to remove second item, which is list of colors

3 Answers

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

Your code looks correct to me. Make sure you aren't removing the code from the previous challenge to remove the 5. If you do, the challenge fails even if the remove red, blue green is correct.

These are the two lines that passed for me in the last step which look like yours.

states.remove(5)
states.remove(['red', 'green', 'blue'])

If it still fails, try refreshing your browser and start the challenge again.

Florian Tönjes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 Points

Hey Nursultan,

your code should work.

This completed the challenge:

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

Kind Regards, Florian