In python, inline methods that work in place return None to make it absolutely transparent that they mutated the object.
Of course, you can ignore this convention and write your own wrapper:
def my_remove(lst,what): lst.remove(what) return lst
But I would not recommend it.
As a side note, if you want to do something like:
list(something_convertible_to_list).remove('item')
but return the list, the following may be useful enough to be useful:
[x for x in something_iterable if x != 'item']
And this returns the list, but where list.remove removes only 1 'item' , this will lead to the creation of a new list without the 'item' in it.
source share