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

What did I do wrong in the removal of items in a list wrong?

I removed the <,> after the number <5> I created a <list_in_list> with [] around the number 5 I used list_in_list.remove([5])

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

2 Answers

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

Hi there, maike! You've recreated the states list and made an entirely different list. Then you changed the 5 to be a one element array/list with 5 in it. None of this was asked for by the challenge. Then you removed the array containing the 5 from the list_in_lists. But the challenge asks you to remove the 5 from the states list. At this point, the states list still contains the 5. You've not altered it at all.

Here's a hint: the solution to this challenge is one short line of code. Remove the 5 (not an array) from the states list.

Hope this helps, but let me know if you're still stuck! :sparkles:

maike willuweit
maike willuweit
552 Points

thanks, I got this through! this was a misunderstanding on List_in_lists - I initially thought this was a command or similar during the video - got completely confused. Thanks again!