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?
See also: Why do these list operations (methods) return None, rather than the resulting list?
Don’t use append but concatenation instead:
This returns a new list;
myListwill not be affected. If you need to havemyListaffected as well either use.append()anyway, then assignyourListseparately from (a copy of)myList.