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 trialTyler Warren
Courses Plus Student 1,033 PointsDon'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
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
Tyler Warren
Courses Plus Student 1,033 PointsI tried states.remove(5) and that worked just fine in workspace but it says it's wrong here.
1 Answer
Gerald Wells
12,763 PointsYou can treat this as garbage collection.
garbage = states.pop(len(states)-1) #this will remove the last indexed value
Gerald Wells
12,763 Pointsor
states = states[:-1] #here you need to be aware of variable scope
Zachary Williamson
Python Web Development Techdegree Student 3,347 PointsZachary Williamson
Python Web Development Techdegree Student 3,347 PointsSo what code have you tried, that's returning an error?