Why do these two operations ( append() and + ) give different results?
>>> c = [1, 2, 3] >>> c [1, 2, 3] >>> c += c >>> c [1, 2, 3, 1, 2, 3] >>> c = [1, 2, 3] >>> c.append(c) >>> c [1, 2, 3, [...]] >>>
In the latter case, there is actually infinite recursion. c[-1] and c same. Why is this different from operation + ?
python list append nested-lists
ooboo Jan 07 2018-10-17T00: 00Z
source share