Can this be reduced to a single line (after assigning a)?
a
a = [1,2,3] b = a[:] b.append(4)
The following is probably the simplest:
b = a + [4]
Here, you don't need a[:] since we're no longer copying the reference (+ creates and returns a new list anyway).
a[:]
+
2.1m questions
2.1m answers
60 comments
57.0k users