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 trialjamie Macdiarmid
2,048 Pointsstuck again.
states.remove (['red', 'green', 'blue'])
Whats wrong now?
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove(5)
states.remove (['red', 'green', 'blue'])
2 Answers
Josh Keenan
20,315 PointsHey Jamie, it's a weird challenge isn't it?
Here's my solution to the challenge, instead of explicitly typing the list you want to remove, I just found the index in the list and removed it that way.
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove(5)
states.remove(states[1])
Ryan Ruscett
23,309 PointsHola,
No worries, you are right and definitely on the right track. The only problem is the space.
states.remove (['red', 'green', 'blue']) < ----- REMOVE the space between removes and the ().
LIKE THIS
states.remove(['red', 'green', 'blue'])
Aside from that, you got it!
jamie Macdiarmid
2,048 Pointsthanks Ryan. Appreciate your time
Ryan Ruscett
23,309 PointsRyan Ruscett
23,309 PointsThis is also a clean way to do it. In a production setting, this would be more accurate. It ensures the list item itself is removed, and not just the values from the list, which in some situations could leave an empty list behind. Which we may or may not want.
jamie Macdiarmid
2,048 Pointsjamie Macdiarmid
2,048 Pointsthanks Josh. much appreciated
jamie Macdiarmid
2,048 Pointsjamie Macdiarmid
2,048 PointsThanks dude. Don't really understand your way but thanks anyway