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

Jim Awofadeju
Jim Awofadeju
4,097 Points

The syntax of the list stored in the variable states is strange. What is the last item that I should remove?

It looks like there are multiple lists held in the variable states. The syntax is different from what was shown in the video. In the workspace, all lists were stored in variables and were on one line. This list is stored in a variable, but it is spread across multiple lines. Is there a list within this list? What is the last item that I should remove? Could someone please make this list easier to read? Thank you.

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

states.remove('red')

2 Answers

Yes, you have it right. There is one list, and inside that list there is another list. Re "multiple lines". Yes, that is an option. Some think it makes it clearer what is in the list. The item to remove in the last challenge is the list inside the list:

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

Remember, when doing challenges you don't replace your work for previous challenges. You keep that work and add the next challenge's work under it. So in the above I show how your final answer should appear.

Jim Awofadeju
Jim Awofadeju
4,097 Points

I was able to complete the two challenge tasks with your explanation and provided code. Thank you.