Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Paul Conlan577 Points
I cannot .remove the last item in list is the 5 and there are extra brackets that don’t match but keep getting arguments
states = ['ACTIVE','red', 'green', 'blue','CANCELLED','FINISHED', 5] states.remove(5)
Oszkár FehérTreehouse Project Reviewer
Hi Paul. Your statement working fine, but you shouldn't change the original list. In the quiz it's a list which look like this:
states = [ 'ACTIVE', ['red', 'green', 'blue'], 'CANCELLED', 'FINISHED', 5, ]
There is a list in the list! I tried your code with this list, what the quiz gives and it pass. Happy coding
Dan Garrison22,445 Points
The challenge is asking you to only remove the last item on the list, which you can do by using the index. Now, you could count starting at 0 and determine which index the last item is. Or you could use -1 as the index as this will always give you the last item on the list regardless of how many items are on it or what the item is.
So your code would look something like this:
Sigurd Melsom6,107 Points
You should remove the last element of the list. You can do it by:
states.remove( states[-1] ) # states[-1] gives the value of the last element