使用 step0 和 step1 以及结果子步骤停止循环 python

Stop for loop python with step0 and step1 with consequence sub-step

如何停止这个for循环,我想做1次step0然后开始while循环5次然后停止。

for x in range (5):
    print("step0")
    while x >= 0:
        print("step1")
        for x in range (5):
            print("sub-step",x)

结果(无限循环)

step0
step1
sub-step 0
sub-step 1
sub-step 2
sub-step 3
sub-step 4
step1
sub-step 0   
sub-step 1
sub-step 2
sub-step 3
sub-step 4
step1
sub-step 0
sub-step 1
sub-step 2
sub-step 3
sub-step 4
.....................

预期结果

step0 (1 times)  
step1 (5 times)
   sub-steps(following step1)

I want to do step0 1 time

那就不要添加 for 循环。为step0保留for循环的目的是什么?

then start the while loop 5 times then stop.

为要执行 5 次的部分添加计数器变量或简单的 for 循环。

print("step0")
for x in range (5):
   print("step1")
   for i in range (5):
     print("sub-step",i)

下次试着想好每一步,step0只调用一次,为什么要放到for循环里?

Step1被调用了5次,你明白了,一个for循环,然后每次调用step1都会调用5次substep,所以每次调用step1,for-loop substep 5次,gl !