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

How can you remove a list in list while it already removed in an earlier command the 2/2 question itself is wrong

Already in question 1 the list of colors removed using

states.remove(['red','blue',''green']}

how can it be removed again in question 2 again
without assigning the colors back

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

states.remove(['red','green','blue'])
states.remove(5)

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hey Mohammed,

I'm not sure, but you seen somewhat confused here.

The first task in the challenge asks: " ... Use the .remove() method to remove the last item from the list, please."

The second task in the challenge says: "OK, one more removal. See that second item in states? It's a list of colors and doesn't belong here. Can you get rid of it for me? Be sure to use .remove() again."

states.remove(5) #Task 1 of the Challenge
states.remove(['red', 'green', 'blue']) #Task 2 of the challenge

Maybe you misread? But your code is all correct. :)

This thread helped answer my question even now. Still relevant! I was trying to use double quotes to remove the colors instead of single, didn't realize that mattered till I read this thread.

why won't .remove(2) delete the list of colors? Also wouldn't deleting the last item be .remove(4) since it starts from 0?