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 57,147 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