使用循环一次又一次的迭代

时间:2021-02-19 12:28:50

标签: loops for-loop foreach while-loop nested-for-loop

我想一次又一次地循环, 就像你从 0 到 4 一样。 达到 4 后,它再次从 0 开始。 可能吗?

while True:
   while I <10:
       if I <=5:
        for c in a:
         run.chat(i)
         i+=1
       else:
           continue

这是真正的代码吗?

1 个答案:

答案 0 :(得分:0)

当然,只要到达边界就重置变量:

i = 0
while True:
    print(i)
    i += 1
    if (i > 4):
        i = 0
相关问题