[英]Replacing elements within a python list
I am trying to go through numbers until the first index is 5, and not zero.我正在尝试通过数字 go 直到第一个索引为 5,而不是零。
'''python''' '''Python'''
lst= [0,1]
while lst[0] != 5:
lst[0]=+1
print(lst)
'''' ''''
with this, it only makes the first index 1. I am trying to continuously add one to the first index until it is 5.有了这个,它只会使第一个索引为 1。我试图不断地将一个添加到第一个索引,直到它为 5。
lst[0]=+1
is equivalent to lst[0] = 1
. lst[0]=+1
等价于lst[0] = 1
。 What you are looking for is:您正在寻找的是:
lst[0] += 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.