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

David Barnhart
David Barnhart
1,049 Points

Is there a way to find the answer to Challenge Tasks if I'm unable to process the correct code?

Please provide the answer to the remove. challenge question. I'm stuck.

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

2 Answers

Hi David,

This challenge requires you to use the remove() method on the given states list.

The remove method takes the item that you want to remove as a parameter. So, for the first challenge, removing the last element in the list; that's a number 5 so you call the remove method on states (use dot notation) and pass the parameter in:

states.remove(5)

That gets rid of the 5. The next task is pretty similar; make sure you call the method on the states list, and pass in the thing you want to remove.

Let me know how you get on.

Steve.

[Of course there is a way]("https://www.google.de/#q=Ugh%2C+I+made+this+list+and+now+it+has+some+invalid+pieces+in+it.+Maybe+you+can+help+me+clean+it+up.+Use+the+.remove()+method+to+remove+the+last+item+from+the+list%2C+please.") Edit Treehouse doesnt like links wiht ( or ) :S Google has the answer to almost all older treehouse tasks

But PPPsssssstttt