Python 如果if条件为True,如何从beginn开始For循环
我想知道如果Python 如果if条件为True,如何从beginn开始For循环,python,python-3.x,for-loop,Python,Python 3.x,For Loop,我想知道如果条件为True,如何从0开始for-循环 for i in range (3): if a=1: #leave if-condition and start from beginning in for-loop with i=0 Break在这里没有帮助,因为使用Break,我只能离开if条件,但我还想从头开始for循环。我想你可以这样写 if 1 == a: for i in range(3): pass 您可以尝试此方法而不是for循
条件为True,如何从0开始for
-循环
for i in range (3):
if a=1:
#leave if-condition and start from beginning in for-loop with i=0
Break在这里没有帮助,因为使用Break,我只能离开if条件,但我还想从头开始for循环。我想你可以这样写
if 1 == a:
for i in range(3):
pass
您可以尝试此方法而不是for循环
i = 0
while i < 3:
if a == 1:
i = 0
i += 1
i=0
而我<3:
如果a==1:
i=0
i+=1
如果a等于1,这将继续遍历循环