0
连接到节点 1
和 2
,因此在索引 0
处插入这两个节点,依此类推。程序应该接受用户的输入。为了简单起见,我写了这段代码。
l = [[]]*4
l[0].append(1)
l[0].append(2)
l[1].append(0)
l[1].append(3)
l[2].append(0)
l[2].append(3)
l[3].append(1)
l[3].append(2)
print(l, end="\n")
但是输出是
[[1, 2, 0, 3, 0, 3, 1, 2], [1, 2, 0, 3, 0, 3, 1, 2], [1, 2, 0, 3, 0, 3, 1, 2], [1, 2, 0, 3, 0, 3, 1, 2]]
我想要第二张图片中的输出。如何实现?