Recursive reference to a list within itself [duplicate]
问题 This question already has answers here : Why does list(my_list) modify the object? (2 answers) Closed 5 years ago . So I came across something very weird in python. I tried adding a reference to the list to itself. The code might help demonstrate what I am saying better than I can express. I am using IDLE editor(interactive mode). >>>l=[1,2,3] >>>l.append(l) >>>print(l) [1,2,3,[...]] >>>del l[:-1] >>>print(l) [[...]] So far the output is as expected. But when I do this. y=l[:] print(y) To me