why does list's .remove() does not return an object?

Abdur-Rahmaan Janhangeer arj.python at gmail.com
Thu May 17 11:26:28 EDT 2018


On 2018年5月17日, 18:55 Ned Batchelder, <ned at nedbatchelder.com> wrote:
> On 5/17/18 4:23 AM, Abdur-Rahmaan Janhangeer wrote:
>> if then a more convenient way might be found to naturally remove and
> return the list
>> maybe it was not included as one might want to remove the list only
>> x = [1]
> x.remove(1)
>> as opposed to
>> x = [1]
> x.remove(1)
> new_list = x
>> i was looking for like
>> x = [1]
> x.remove(1).return()
>>> I don't understand what this would return? x? You already have x. Is it
> meant to make a copy? x has been mutated, so I don't understand the benefit
> of making a copy of the 1-less x. Can you elaborate on the problem you are
> trying to solve?
>> --Ned.
>>assignment to another var
>>


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /