Because the function append() modifies the list and returns None .
One of the best ways to do what you want to do is to use the + operator.
Take your example:
>>> x = [4, 5] >>> y = x + [7] >>> x [4, 5] >>> y [4, 5, 7]
The + operator creates a new list and leaves the original list unchanged.
madhuspot
source share