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

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!

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

2 Answers

Jennifer Nordell
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.


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!