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

James Young
PLUS
James Young
Courses Plus Student 182 Points

remove function in list

i have created a list_in_list, added the .remove()with the section i want removed, just as shown in the video, but it keeps saying "bummer, did you use '.remove()'

the anser is "YES!!!"

list_in_list = ['red', 'green', ['blue']] list_in_list.remove(['blue]) list_in_list

lists.py
states = [
    'ACTIVE',
    ['red', 'green', 'blue'],
    'CANCELLED',
    'FINISHED',
    5,
]
list_in_list = ['red', 'green', ['blue']]
list_in_list.remove(['blue'])
list_in_list
James Young
James Young
Courses Plus Student 182 Points

****My second attempt, but still getting the same bummer error******

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

1 Answer

Steven Parker
Steven Parker
231,271 Points

The challenge is expecting you to remove the items(s) from "states".

But you created a separate list ("list_in_list") and removed from that instead. So re-write your code to remove from the supplied list "states".

Also, in a multi-task challenge, each task builds on the others. So remember as you progress through the tasks, leave the code you did before as it is and add the new task code below it.