How to allow list append() method to return the new list
list.append
is a built-in and therefore cannot be changed. But if you're willing to use something other than append
, you could try +
:
In [106]: myList = [10,20,30]In [107]: yourList = myList + [40]In [108]: print myList[10, 20, 30]In [109]: print yourList[10, 20, 30, 40]
Of course, the downside to this is that a new list is created which takes a lot more time than append
Hope this helps