【发布时间】:2017-06-16 10:37:08
【问题描述】:
我有下面的代码,它会打印我需要的内容,但我需要代码根据 def 函数执行两次。我敢肯定这很简单,但我一辈子都想不通
def countdownWhile(n, max_repeat):
# display countdown from n to 1
while n > 0:
print (n)
n = n-1
if n == 0:
print('blast off')
我在运行代码时得到以下输出:
>>> countdownWhile(5,2)
5
4
3
2
1
blast off
>>>
【问题讨论】:
标签: python python-3.x