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

Tyler Warren
PLUS
Tyler Warren
Courses Plus Student 1,033 Points

Don't know how to remove last thing

Don't understand what I'm supposed to do I guess. It's saying what I'm deleting isn't in the list

lists.py
states = [
    'ACTIVE',
    ['red', 'green', 'blue'],
    'CANCELLED',
    'FINISHED',
    5,
]
Tyler Warren
Tyler Warren
Courses Plus Student 1,033 Points

I tried states.remove(5) and that worked just fine in workspace but it says it's wrong here.

1 Answer

You can treat this as garbage collection.

garbage = states.pop(len(states)-1)  #this will remove the last indexed value

or

states = states[:-1]  #here you need to be aware of variable scope