【发布时间】:2020-07-03 07:52:12
【问题描述】:
是否可以在 for 循环运行后更改它,然后在下一次迭代中返回并更改它?
#the code example
score = 50
running = True
while running:
for rounds in range(0, 6):
for rounds in range(0, 6):
if input() == x:
score - 3
print(score)
elif input() == y:
score - 2
print(score)
elif input() == z:
score - 1
print(score)
elif input() == **change**:
#Edit previous loop input because of an error or typo(x should have been z previous iteration) #How would one make this happen?
【问题讨论】:
-
您能否详细说明更改循环的含义?
-
我不太明白你的问题。但是一件事是错误的,您在内部循环中重用了变量
rounds。您应该为该名称使用不同的名称。 -
无法撤销。如果你运行代码,它已经发生了。最好的办法是在运行和进行测试之前检查拼写错误。
-
我想让输入改变分数,在我们通过循环时降低分数。但是如果前一个循环的前一个输入是错误的,它可以在当前循环中改变它。我收到了一个答案,说我可以添加相同的数量来修复它。