这是我的代码,我得到了两个不同的输出,分别是 [2] 和 [2,4,6],有人可以解释一下吗?
list = [1,2,3]
def getdouble(l):
result = []
for i in l :
i = i * 2
result.append(i)
return result
print getdouble(list)
def getdouble_v2 (l):
result = []
for i in range(len(l)):
l[i] = l[i] * 2
result.append(l[i])
return result
print getdouble_v2(list)