What is the different between list1.append(list2) and list1.append(list2[:]) in a for loop in Python?

前端 未结 0 1403
温柔的废话
温柔的废话 2021-01-23 10:10

Here are two pieces of similar codes:

s=\'abc\'
ans,res=[],[]
for i in range(len(s)):
    ans.append(i)
    res.append(ans[:])
print(res,"\\n")
<         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题