请问python如何统计循环次数

刚学python不久,这是一道练习题出自《python编程,从入门到实践》第九章类,代码是为了描述彩票中大奖要多难,前面的已经打好了,但是最后要求报告循环次数实在是想不出了。
img
img
img

#以下是代码的手打版本,图片上有电脑上打的
from random import choice
a =[1,2,3,4,5]
while True:
one =choice(a)
if one ==5
print(one)
else:continue

       two = choice(aif   two ==4
            print(twoelse:continue

       three = choice(aif   three ==3
            print(threeelse:continue

         if one ==5 and two4 and three3

print(“恭喜您中奖了”)
break

很好奇你的代码是怎么跑起来的,你试一试我的

img

img

我设置了跑10000000000000.0次后自动停止,有用的话点一下采纳

循环体外设置一个变量m=0,
在循环体内开头添加m+=1
然后print("第 %s 次循环"%m)
还有你的代码里有的地方存在缩进错误,建议你修改一下
如果我的回答对你有用,点击右上角给个采纳哦~