Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics (2015) Python Data Types Lists

does the remove method remove only one argument?

Here in this video they had a list [1, 2, 3, 4, 5, [6, 7, 8,]] where they were able to remove [6, 7, 8] from the list. But isn't that considered to be more than one argument? or is the list inside of a list considered to be just one argument? Also, for instance, what if I had a list [1,2,3] and I wanted to remove all of them at once using the remove method to end up with an empty list. Would that be possible?

Any input would be much appreciated thank you

3 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 66,632 Points

Here in this video they had a list [1, 2, 3, 4, 5, [6, 7, 8,]] where they were able to remove [6, 7, 8] from the list. But isn't that considered to be more than one argument?

remove is looking to match a single object. In this case, the single object is a list that happens to contain multiple items.

or is the list inside of a list considered to be just one argument?

Correct.

Also, for instance, what if I had a list [1,2,3] and I wanted to remove all of them at once using the remove method to end up with an empty list. Would that be possible?

As this list contains three items, each item would need to be removed in a separate remove statements. Although, if you truly are removing all the elements then setting the list to the empty list would work: = []

G Johnson
G Johnson
46,427 Points

The list inside of a list is considered to be one element.

That cleared my doubts. Thank you guys