For循环未运行

时间:2018-10-16 02:26:36

标签: python python-3.x for-loop

T = 2
AList = [[0,0,0,0,0], [0,0,0,0,0]]
BList = [[1,2,4,2,3], [1,2,4,2,4]]

def magic(i):
    AList[t][i] = int(AList[t][i]) + 1
    AList[t][i+1] = int(AList[t][i+1]) + 2
    AList[t][i+2] = int(AList[t][i+2]) + 3

for t in range(T):
    nie = False
    for i in range(len(AList[t]) - 2):
        Diff = int(int(AList[t][i]) - int(BList[t][i]))
        if Diff > 0:
            print('NIE')
            nie = True
            break
        elif Diff == 0:
            pass
        else:
            for r in range(Diff): #Here, this loop doesn't work
                print('asd')
                magic(i)

以上代码中的注释循环似乎无效。 每当我删除循环并将其内容放入循环外部时,它就会再次开始工作。 我已经尝试了从将其更改为while循环到更改其上方的if语句的所有操作。 我正在谈论的循环是代码的倒数第三行。

0 个答案:

没有答案