I want to do something like this:
myList = [10,20,30]
yourList = myList.append (40)
Unfortunately, list append does not return the modified
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