在Python中对元素进行修改的方法
1.使用range函数修改
l = list(range(10)[::2])print (l)for i in range(len(l)):l[i] = 0print (l)
l = list(range(10)[::2])
print (l)
for i in range(len(l)):
l[i] = 0
2.使用enumerate函数修改
l = list(range(10)[::2])print (l)for index,value in enumerate(l): l[index] = 0print (l)
for index,value in enumerate(l):
l[index] = 0