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

Matthew Williams
Matthew Williams
3,103 Points

I need help removing two or more items from lists.

I'm trying to remove '5' and the colors in the list. Here's my code.

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

It's confusing me and I have no idea what I'm doing wrong. I thought you add on other attributes with the (,).

1 Answer

Stuart Wright
Stuart Wright
41,118 Points

This is not possible to do in one statement, at least not using techniques taught so far in this course. You need to break it up into multiple statements:

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

If you are keen to find a way to do this in one line, you can read the discussion here:


But like I said, you would not be expected to be able to do this in one line at this stage in the course.