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 trialIndra Bergmans
2,199 PointsI'm struggling with the .remove in Python.
Now I have to remove the colours from the list, besides the already removed '5'. How do I do this? I have to use the code that was used to remove the '5'.
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove('red', 'green', 'blue'), (5)
4 Answers
Steven Parker
231,269 PointsEach remove operation will be done on a separate line.
You'll keep the line you did for task 1, but add more code under it.
Also, when removing a sub-list, remember to put the brackets []
around the list items in your argument.
Indra Bergmans
2,199 PointsHello Steven,
I tried doing the same I did for the first task, for the second one. I did the code under the first task, but it didn't accept it. I'm still not getting it apparently...
Steven Parker
231,269 PointsShow what your revised code looks like.
Indra Bergmans
2,199 PointsI did this:
states.remove(5) states.remove[('red', 'green', 'blue')]
Steven Parker
231,269 PointsNow it just looks like you have your brackets and parentheses reversed. The list goes in the brackets [] and then all that goes inside the parentheses () that come after the method name.
Indra Bergmans
2,199 PointsThat was it! I'll probably have to repeat this part a few times to get it down. Thanks for your help Steven!