我最近开始学习Python,并且有一个倒数计时器。它工作正常,但我想在输出中添加一个星号。

重新生成的输出是:

Countdown timer: How many seconds? 4
4****
3***
2**
1*
Blast off


到目前为止,我有:

import time

countDown = input('Countdown Timer: How many seconds?')

for i in range (int(countDown), 0, -1):
    print (i)
    time.sleep(1)
print ('BLAST OFF')

最佳答案

以下代码将起作用:

import time

countDown = input('Countdown Timer: How many seconds?')

for i in range (int(countDown), 0, -1):
    print(i*'*') # This will print i number of '*'s
    time.sleep(1)
print ('BLAST OFF')

关于python - 在输出中添加一个星号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43228584/

10-17 00:39