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.

Python Python Basics (2015) Python Data Types list.remove()

On the challenge task list.remove its asking me to remove the value 5. I tried states.remove([5]) what am I doing wrong?

states = ['ACTIVE', ['red', 'green', 'blue'], 'CANCELLED', 'FINISHED', 5,] its asking to remove the last value (obviously 5) but it keeps saying that 5 wasn't found in the list!

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

2 Answers

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

Hi there! You're trying to remove an element that doesn't exist. That's a normal 5 in there. You're trying to remove an array that contains a 5. All you need to do is remove the brackets around the 5 in the remove statement.

states.remove(5)

Happy coding! :sparkles:

Ah I see what I did wrong. Thank you!

Just some feedback on this part of the lecture where my note-taking caught this expression taught for removing parts of lists, within lists was demonstrated as ">>>list_in_list.remove = ([4,5,6])", next commanded to demonstrate the change resulting in this ">>>list_in_list" with the response "[1,2,3]". I feel this area of information, however caught in an unexpected challenge, that this needs a bit more explanation in the lecture. I suggest a side video to add to this course that goes over the syntax and its structures a bit further before this challenge. I found this answer to be most sufficient in resolving the confusion. Did I see in the lecture that it was demonstrated with the equal sign or without? Does this depend on the version of the Python language that is being used or demonstrated? Or would that vary amongst, say, database interactions?

Sorry for the lengthy response. Loving this course so far!