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

Ned Batchelder ned at nedbatchelder.com
Wed May 16 23:01:40 EDT 2018


On 5/16/18 10:41 PM, Abdur-Rahmaan Janhangeer wrote:
> why is x = list.remove(elem) not return the list?
>
>
Methods in Python usually do one of two things: 1) mutate the object and 
return None; or 2) leave the object alone and return a new object.  This 
helps make it clear which methods mutate and which don't.  Since .remove 
mutates the list, it returns None.

--Ned.



More information about the Python-list mailing list