我想知道如何将列表中的某些项目乘以0以再次使列表空白。我之所以需要这样做,是因为我已经在代码中实现了圆形系统。
totalround1 = [coupleAtotal ,coupleBtotal,coupleCtotal,coupleDtotal,coupleEtotal,coupleFtotal]
totalround1.sort()
print(totalround1)
index0= totalround1[0]
index1= totalround1[1]
index2= totalround1[2]
index3= totalround1[3]
index0 * 0
index1 * 0
index2 * 0
index3 * 0
print(index0,index1,index2,index3)
它返回与以前相同的值,我想知道如何解决此问题。
答案 0 :(得分:0)
您实际上并没有在代码的后半部分更改索引。您只是将它们乘以零而不存储它们。这样做:
totalround[2] = 0
代替