以下代码中不执行“ i = i-1”操作的原因是什么?

时间:2018-09-18 15:08:46

标签: python

我想在python列表中输入10到20之间的8个数字。但是“ i = i-1”操作不起作用,在for循环中,列表中的数据都无法获取。我正在使用python 2.7.1。

values = [None] * 8

for i in range(8):
    x = int(input("Enter a number : "))

    if x < 10 or x > 20:
        i = i - 1
    else:
       values[i] = x

print values

image :output of the code

image of the code

0 个答案:

没有答案