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

maike willuweit
maike willuweit
552 Points

How to remove an item in a list with the .remove() option? Basic course exercise

I am learning the python basic course. How to remove items in a list using the .remove() option.

I have had various attempts, but seem to miss out some basic part / parts...

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

same thing i was just trying to figure out

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi again, maike willuweit! I regret that the hints I left in this post weren't enough to get you through the first step of the challenge.

Here is my solution:

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

states.remove(5)

This line runs the remove method on the states list and removes the 5. Only this line is needed for the first step.

Hope this helps! :sparkles:

maike willuweit
maike willuweit
552 Points

Thanks again, I re-posted this one as I wasn't sure if my initial question was posted... Your first comments / hints were good!