I want to do something like this:
myList = [10,20,30]
yourList = myList.append (40)
Unfortunately, list append does not return the modified list.
So, how can I allow append
to return the new list?
Don't use append but concatenation instead:
yourList = myList + [40]
This returns a new list; myList
will not be affected. If you need to have myList
affected as well either use .append()
anyway, then assign yourList
separately from (a copy of) myList
.