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

Tolgay Yilmaz
Tolgay Yilmaz
306 Points

task wants me to remove the last item, which is: '5', but when I type states.remove('5'): don't change states directly.

task wants me to remove the last item, which is: '5', but when I type states.remove('5'), It is prompted I shouldn't directly change the variable: states. then I tried to assign remove operation to states variable back, that also wouldn't work.

thing is, it works on the console interpreter just fine.

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

states = states.remove('5')

2 Answers

Jennifer Nordell
Jennifer Nordell
Treehouse Teacher

You've told it to remove the the string '5' which doesn't exist. The 5 in there is an integer. Just drop the quotes and you should have it. Take a look here:

states = [
    ['red', 'green', 'blue'],

Tolgay Yilmaz
Tolgay Yilmaz
306 Points

Thank you, it worked of course :)