【发布时间】:2020-08-25 11:29:42
【问题描述】:
如何打印 while 循环运行了多少次?
例子:
from random import*
c=0
while c<3 :
a=randint(1,6)
b=randint(1,6)
if a==b:
print(a,b)
c=c+1
【问题讨论】:
-
添加一个
counter变量,每次迭代都会(无条件地)增加?
标签: python while-loop