更新
This commit is contained in:
18
Python-100-Days/Day66-75/code/generator02.py
Normal file
18
Python-100-Days/Day66-75/code/generator02.py
Normal file
@@ -0,0 +1,18 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user