#First you need to define your center_x. You may get this value from some other
#function in your script. I will use 160 as a valid example
center_x = 160
#You need to define initial value of x outside of the loop so it does not "reset"
x = 200
if 150 <= center_x <= 180:
while x <= 600: #Here you set the limit of where you want to stop adding. I used 600 as example
x += 100
print(x) #There is no need to set a MESSAGE variable, you can directly print the x variable
我假设这段代码在而True循环中。如果是这样,那么问题在于每次迭代时将x设置为200,然后将其增加100,每次迭代时给出300。您应该将起始值指定给循环外部的x
尝试将其更改为以下内容:
相关问题 更多 >
编程相关推荐