您如何覆盖列表中的项目?
我尝试过,但是没有用。
numbs = [5, 10, 15, 20, 25]
i = 0
for numb in numbs:
numbs[i] = (numb+5)
i+=i+1
答案 0 :(得分:1)
尝试一下:
numbs = [numb+5 for numb in numbs]
答案 1 :(得分:0)
尝试一下:
numbs = [5, 10, 15, 20, 25]
i = 0
for numb in numbs:
numbs[i] += 5
i += 1
print(numbs)
我从中得到的输出是:[10,15,20,25,30]