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

Soufiane Bdaoui
Soufiane Bdaoui
9,602 Points

There is a way to remove multiple items from a list with .remove()?

As the title, I'm starting the python track and I was experimenting with the .remove() method. It is possible to pass multiple items in the method?

Also, is there any difference between methods and functions?

3 Answers

Anibal Marquina
Anibal Marquina
9,523 Points

maybe this one can help you! states = [ 'ACTIVE', ['red', 'green', 'blue'], 'CANCELLED', 'FINISHED', 5,] states.remove(['red', 'green', 'blue'])

A function is a few lines of code that we want to be able to trigger at any point.

Objects represent something with concrete attributes. "methods", represent actions that the object(str or list) can do.

Soufiane Bdaoui
Soufiane Bdaoui
9,602 Points

I got the method-function difference but I still can't understand if I can remove more items from a list with .remove. What you did what to remove a single item ['red', 'green', 'blue'], that happened to be also a list. Still it should count as one item.

Let's take the example that you made: I want to know if there is a way to remove both 'ACTIVE' and ['red', 'green', 'blue'] with the .remove method.

Thanks for answering tho.