刚学python不久,这是一道练习题出自《python编程,从入门到实践》第九章类,代码是为了描述彩票中大奖要多难,前面的已经打好了,但是最后要求报告循环次数实在是想不出了。
#以下是代码的手打版本,图片上有电脑上打的
from random import choice
a =[1,2,3,4,5]
while True:
one =choice(a)
if one ==5
print(one)
else:continue
two = choice(a)
if two ==4
print(two)
else:continue
three = choice(a)
if three ==3
print(three)
else:continue
if one ==5 and two=4 and three=3:
print(“恭喜您中奖了”)
break