Files
06-Note/Python-100-Days/Day66-75/code/generator02.py
sherlockforrest bf2ed2e31f 更新
2023-06-20 09:22:53 +08:00

19 lines
255 B
Python

from time import sleep
def countdown(n):
while n > 0:
yield n
n -= 1
def main():
for num in countdown(5):
print(f'Countdown: {num}')
sleep(1)
print('Countdown Over!')
if __name__ == '__main__':
main()