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 trialJonas Vaškevičius
398 Pointshow to remove list,that is in the list?
how to remove the list, that is in the list?
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove(5, ['red', 'green', 'blue'])
1 Answer
andren
28,558 PointsPassing in the list you want to remove as an argument is the correct way, the issue is that the remove
method only supports removing one item at a time. Which means that you can't give it multiple arguments like you are doing.
If you simply call remove
twice like this:
states = [
'ACTIVE',
['red', 'green', 'blue'],
'CANCELLED',
'FINISHED',
5,
]
states.remove(5)
states.remove(['red', 'green', 'blue'])
Then your code will work.